Skip to content

avoid ext/XS-APItest/t/clone-with-stack.t crash #21979

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

Closed
wants to merge 1 commit into from
Closed

Conversation

iabyn
Copy link
Contributor

@iabyn iabyn commented Feb 12, 2024

a fresh_perl() TODO test in this file does something like

use XS::APItest;
BEGIN {
    clone_with_stack();
}
print "ok\n";

As a standalone program, this code gives errors under valgrind, and in ticket GH #21969 was causing "perl.exe has stopped working" on Windows 8.

The clone_with_stack() XS function is fairly dodgy - it clones the whole interpreter including stacks (i.e. what fork() emulation on windows does), but then continues the RUNOPS loop to completion itself, using the cloned interpreter, rather than relying on the caller to finish the ops loop.

This doesn't work very well under BEGIN (hence why it's a TODO test), but specifically, PL_curcop can be left pointing at an op which gets freed , but then is later accessed anyway.

This commit resets PL_curcop to &PL_compiling to avoid crashes.

a fresh_perl() TODO test in this file does something like

    use XS::APItest;
    BEGIN {
        clone_with_stack();
    }
    print "ok\n";

As a standalone program, this code gives errors under valgrind,
and in ticket GH #21969 was causing "perl.exe has stopped working" on
Windows 8.

The clone_with_stack() XS function is fairly dodgy - it clones the whole
interpreter including stacks (i.e. what fork() emulation on windows
does), but then continues the RUNOPS loop to completion itself, using
the cloned interpreter, rather than relying on the caller to finish the
ops loop.

This doesn't work very well under BEGIN (hence why it's a TODO test),
but specifically, PL_curcop can be left pointing at an op which gets
freed , but then is later accessed anyway.

This commit resets PL_curcop to &PL_compiling to avoid crashes.
@iabyn iabyn closed this Feb 16, 2024
@iabyn iabyn deleted the davem/clone branch February 16, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants