-
Notifications
You must be signed in to change notification settings - Fork 556
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
Feature 'class' Segmentation fault in DESTROY phase for improperly constructed instance #22278
Comments
I do get the |
Good spot, I've amended the report. @ilmari also pointed out, which might be useful for those looking for this type of lifecycle management, that spelling it |
Building a debug perl yields this:
Indeed the issue is that the object isn't fully-constructed at this point, so some of its SV pointers in the fields array are still NULL. There's two potential approaches to fixing this:
Overall I feel that option 1 is probably better here, as it involves far smaller code change. A single extra NULL pointer comparison is unlikely to make a huge impact as compared to making all constructors quite a bit slower. |
But why is the destructor called at all? |
Perl calls Certainly we could create (and encourage folks to use) a separate |
It seems the wider topic of how destructors ought to work is still a thing that needs discussing, though I don't think this bug is the place to do it. I'd suggest we begin a separate discussion about that to look at the wider topic overall. |
Module: core feature 'class'
Description
Referencing a required
:param
class member in DESTROY, which had not been correctly initialised during instantiation, triggered a Segmentation fault.FAO @leonerd, @ilmari - following up on IRC conversation. Many thanks!
Steps to Reproduce
This script is the most whittled-down example I could produce which exhibits the behaviour:
Expected behavior
Additional error:
Can't call method "cleanup" on an undefined value
Perl configuration
The text was updated successfully, but these errors were encountered: