infinite recursion in malloc() with some compile flags
Apologies if you see this twice, but I'm afraid my first attempt
fell into a black hole. Neither Achim's archive nor the NNTP
gateway seem to have recieved it.
If one tries to compile perl with all of
-DPACK_MALLOC -DHIDEMYMALLOC -DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC
then it's almost certain that miniperl will overflow the C stack on
its first attempt to call malloc().
This happens because with -DPACK_MALLOC Perl_malloc() expects sbrk()
to return 2K-aligned blocks and Perl_sbrk() provides the same sort
of alignments as the system malloc(), i.e. 8 bytes or so.
When Perl_malloc() notices the block returned by sbrk() isn't properly
aligned, it tries to croak("panic: Off-page sbrk"). Croak() calls
mess(); mess() calls mess_alloc(); mess_alloc() calls Perl_malloc();
Perl_malloc() again calls croak() and so on until the C stack overflows.
I see two problems here;
1. With -DPACK_MALLOC, Perl_sbrk() should return 2K-aligned blocks.
2. croak() should not recurse infinitely.
The patch below deals with #1. I'll think some more about #2.
p5p-msgid:
199706240050.CAA10550@xs2.xs4all.nl