Skip to content
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

Issues using Perl exit #14

Open
chrstphrchvz opened this issue Feb 7, 2021 · 1 comment
Open

Issues using Perl exit #14

chrstphrchvz opened this issue Feb 7, 2021 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@chrstphrchvz
Copy link
Owner

Various issues (errors, crashes, segmentation faults) are encountered when Perl exit is called before destroying the main/root window. Examples include:

Tcl::Tk appears to be affected by this as well (https://www.perlmonks.org/?node_id=1191134). I do not know whether wrappers can/should support exit usage, so for now I recommend always destroying the root toplevel before Perl exits (either by entering MainLoop and waiting for the user to close it, or programmatically using the destroy method).

@chrstphrchvz
Copy link
Owner Author

chrstphrchvz commented May 1, 2022

I looked into this a while ago. Perl’s exit relies on C’s longjmp(), which is why perlinterp says “code should always save values using SAVE_FOO rather than in auto variables”. But Tcl sees no problem with keeping its state on the C stack. So embedding Tcl seems to violate Perl’s assumption that XS or C code called from Perl won’t keep important state on the C stack, because it will be clobbered by longjmp(). Once Perl exit has done longjmp(), it is too late for Tcl.xs to call Tcl_Finalize(). I have yet to find if there is a reasonable way to override Perl’s exit so that Tcl_Finalize() can be done before longjmp().

chrstphrchvz added a commit that referenced this issue May 15, 2022
Avoid using Perl exit() in after callback
See #14
chrstphrchvz added a commit that referenced this issue May 15, 2022
Avoid using Perl exit() in after callback
See #14
chrstphrchvz added a commit that referenced this issue May 15, 2022
Avoid using Perl exit() in after callback
See #14
chrstphrchvz added a commit that referenced this issue May 16, 2022
Avoid using Perl exit() in after callback
See #14
@chrstphrchvz chrstphrchvz added the help wanted Extra attention is needed label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant