Bug#816280: Binary incompatibility between debugperl and perl
Nick Wellnhofer
wellnhofer at aevum.de
Mon Feb 29 11:53:33 UTC 2016
Package: perl-debug
Version: 5.20.2-2
The layout of interpreter variables is different in the debug and normal
version of the perl binary. This means that XS extensions might read from or
write to the wrong area of the interpreter variable struct, causing crashes
and other strange behavior.
Here's an example, originally reported by me at
https://rt.cpan.org/Public/Bug/Display.html?id=111211
$ PERL_DESTRUCT_LEVEL=2 debugperl -MList::Util=shuffle -e shuffle
Segmentation fault
This segfaults because `shuffle` calls `seedDrand01` which writes to the
`random_state` interpreter variable. If you have a look at `intrpvar.h` in the
Perl source, you'll see that `random_state` is at the very end with some
variables before that are only enabled in debug builds. This causes
`random_state` to be at a different offset in the debug build. The XS module
`List::Util` uses the non-debug offset, so any writes to `random_state` cause
memory corruption.
I'd propose that all interpreter variables that are only used in the debug
build should be moved to very end in `intrpvar.h`.
More information about the Perl-maintainers
mailing list