-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault in simple program reading from ARGV #19340
Comments
Confirmed with blead@7931406120; miniperl is sufficient,
Stack trace from the assert() shows:
I haven't tried to dig further yet - could this be a stack refcounting issue? |
Yeah recounting seems likely as taking a copy seems to "fix" it:
|
Issue Perl#19340: This prevents an obscure segfault.
Perl_nextargv() sets each argv to SAVEFREESV(). This conflicts with the fact that those same SVs are in |
Issue Perl#19340: This prevents an obscure segfault.
I think that strongly suggests that this is another case of the infamous "the stack is not refcounted" bug. |
Can you possibly point to some previous solutions for this one? Here is another example of what seems to be the same bug (or at least a closely-related one):
|
Issue Perl#19340: Previously if you mapped/grepped over an array and mutated the array within the map/grep, a segfault would happen. This fixes that by bumping the map/grep args' reference count at the start of the map/grep, then enqueueing those args for a refcount decrement at the end.
I can't, unfortunately. Fixing this is a fairly big refactor (one I would be in favor of nonetheless).
Yes, that's exactly the category of bug I'm talking about. |
@Leont Then I’m guessing the refcount-bump fix I just pushed has some drawback, or else someone would likely have already implemented it … |
On Wed, 9 Feb 2022, 08:31 Felipe Gasper, ***@***.***> wrote:
I think that strongly suggests that this is another case of the infamous
"the stack is not refcounted" bug.
Can you possibly point to some previous solutions for this one?
Afaik this is generally considered to be a case of "Doctor, doctor, it
hurts when i stck a fork in my eye." IOW the solution is: so don't do that.
😁
These issues are extremely rare in practice. The only example I can
remember from my career at booking related to Carp::longmess, aka
Carp::confess dumping arguments on the call stack via caller.
The issue comes up all the time with fuzzers and contrived code, but is
more or less unheard of in actually useful production code. As i said, even
with hundreds of devs at booking writing perl I can't recall a single case
of this being reported.
It would be nice to fix the problem, but I can't personally say how easy
that would be, nor what kind of performance consequences it would have. The
fact that none of the relavently skilled internals hackers have taken it on
is suggestive that it is intractable, or at the very least low ROI.
Yves
…
Message ID: ***@***.***>
|
As far as I recall, @iabyn was at one point considering taking this on as his next big project. I don't know if he still is. |
On Wed, Feb 09, 2022 at 04:05:33AM -0800, Hugo van der Sanden wrote:
> It would be nice to fix the problem, but I can't personally say how easy that would be, nor what kind of performance consequences it would have. The fact that none of the relavently skilled internals hackers have taken it on is suggestive that it is intractable, or at the very least low ROI.
As far as I recall, @iabyn was at one point considering taking this on as his next big project. I don't know if he still is.
Either that or Signatures (or both?). Although at the moment, neither, as
evidenced by the fact that I'm only just starting to read through my
5-week backlog of p5p emails :-(.
…--
The Enterprise's efficient long-range scanners detect a temporal vortex
distortion in good time, allowing it to be safely avoided via a minor
course correction.
-- Things That Never Happen in "Star Trek" #21
|
Steps to Reproduce
Run on your command line.
Expected behavior
No segfault.
Actual behavior
Note that the segfault happens regardless of whether the files in
@ARGV
exist or not.Perl configuration
The text was updated successfully, but these errors were encountered: