develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132638] I've discovered a segfault

Thread Previous | Thread Next
From:
Zefram
Date:
December 23, 2017 15:42
Subject:
Re: [perl #132638] I've discovered a segfault
Message ID:
20171223154237.GH19698@fysh.org
shmem wrote:
>Why should a buffer overflow be a bug but a stack overflow should not?

For two reasons.  Firstly, buffer overflow is always an implementation
mistake: Perl doesn't expose fixed-size buffers that the user can
overflow.  Whereas stack overflow is a natural result of the Perl
program: it is the user that coded an infinite recursion.  Secondly,
buffer overflow can cause all kinds of erroneous behaviour, often
exploitable to defeat security measures.  Whereas stack overflow just
causes a segv that terminates the program.

It would be nicer if deep recursion that currently occurs on the C stack
were to be able to use more of the available memory, and eventually fail
in some slightly cleaner way that cites lack of memory.  Simple cases
of Perl recursion do avoid the C stack and get such behaviour.  But it
would be quite infeasible to avoid C stack recursion in all cases, and
very difficult to give C stack recursion nicer behaviour.  So we have
made a tacit design decision that we put up with the limited C stack
size and segv as the result of overflowing it, and thus we let that be
the behaviour we offer to Perl programs.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About