-
Notifications
You must be signed in to change notification settings - Fork 577
Segmentation Fault provoqued by infinite recursion in double quote / stringification overloading #19559
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
Comments
Not a new problem, though I don't know whether it's been reported previously or not.
|
Yeah, I'm pretty sure this is both known and unfixable. Ultimately infinite recursion isn't finite. |
@Leont My first idea is that, infinite recursion is a special case of recursion. And recursive call should be identifiable. |
I don't think we'd want to put a special-case in for this - it would not be appropriate to suppress the overriding function for the duration of the call, the way we do for things like
As @Leont implies, it is the responsibility of the programmer not to recurse without providing termination conditions. The "deep recursion" warning is there precisely so you have a clue why you got a segfault. If you don't get the "deep recursion" warning that might be a bug - but make sure you actually have warnings turned on. (I find that when writing one-liners I always forget that |
You do get the "Deep recursion" warning with warnings on:
I don't think there's a bug here. |
@tonycoz id say we should keep this bug report as we shouldn't segfault, which we do only because these overloads involve the C stack. |
We've closed similar issues in the past. In this case I don't think there's a practical fix for it and it should be WONTFIX, keeping it open would just be noise. I can see a couple of approaches, neither really seems really practical: OPs handling of overloads require a callback approachLet's say I have an op that takes two string parameters, for an overloaded parameter the pp func would need to return to the event loop with another OP that behaves like pp_entersub, calling any overload implementation method, and use some mechanism to continue where it left off. There would need to be some mechanism to store any in progress state of the OP (like the current state of the sort in pp_sort, which is a hairy case) This is all really hairy. OP arguments are pre-overloadedEach argument that wants a particular type (PV, IV etc) has an OP generated that casts the argument to that type, so instead of: pushmark we'd have: pushmark This won't work for some OPs, like printf() or pack(), since the argument types depend on their format arguments. Neither approach works for XSUBs. Both approaches will reduce performance, even for non-overloaded arguments. |
On Thu, Jun 15, 2023 at 05:00:27PM -0700, Tony Cook wrote:
We've closed similar issues in the past.
In this case I don't think there's a practical fix for it and it should be WONTFIX, keeping it open would just be noise.
I can see a couple of approaches, neither really seems really practical:
Also, neither of them would work for the similar recursive tie method
bug, as tied FETCH()s etc can be called from just about anywhere where
the value of an SV is retrieved.
A hacky "fix" would be to record recursion depth (i.e. how many times
call_sv() or similar has been called) and croak on some arbitrary limit,
on the grounds that a croak with a meaningful error message is better than
a SEGV.
Choosing a limit is of course hard - should it be user-settable, and
should the default depend on the platform, and whether the code is being
run within a thread, and so on.
…--
Spock (or Data) is fired from his high-ranking position for not being able
to understand the most basic nuances of about one in three sentences that
anyone says to him.
-- Things That Never Happen in "Star Trek" #19
|
This is what i was thinking. My intent wasn't that this shouldn't throw an error, it was that it shouldn't segv when that error occurs. |
Hi,
I just found out about a Segmentation Fault.
This is my golfed version of the bug :
The infinite recursion call happens when trying to print the arguments on the anonymous subroutine used to overload the double quotes operator.
In the module I am writing, I also got this error message
Deep recursion on anonymous subroutine
but it doesn't appear in the golfed replicate.And this is my perl build :
The text was updated successfully, but these errors were encountered: