-
Notifications
You must be signed in to change notification settings - Fork 567
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
Setting $0 in eval_pv causes core dump #8977
Comments
From perlbug@daveola.comCreated by perlbug@daveola.comSetting $0 in an embedded perl script (such as with eval_pv) causes Example case: --- int my_perl = perl_alloc(); eval_pv( "$0='fubar'" , G_VOID); perl_destruct(my_perl); Perl Info
|
The RT System itself - Status changed from 'new' to 'open' |
From hans@freitag-consulting.deHello together, I am on the look why two well probed Perl script are either coredumping,crashing,producing unforseeable errors, since we After tracing back the calls (which is difficult because you never know which of the good calls is the bad one) we came about a line of my $obj=eval "someclass->new(\$someparam)"; which has some similaritys to the eval that is reported in this bug.
We are still trying to get the problem reproduced, because the Application is a bit bigger, and it also does not fail always. But we have tried different Perl versions, from the 5.8 os version up to a self compiled 5.20.1. regards Hans |
From @wolfsageOn Fri, Jun 22, 2012 at 12:30 PM, Jesse Luehrs via RT
I think this is because arg is declared as: char *arg[] = { "", "-e", "" }; And the code in perl_parse says: ( 1489 /* Set PL_origalen be the sum of the contiguous argv[] I *think* the real issue here is that declaring: char *arg[] = { "", "-e", ""}; seems to make arg[0] a const string, and so unwritable. But how can we Here's example of similar behaviour: mhorsfall@tworivers:~$ cat uh.c int main(void) { strcpy(arg[0], "h\0"); printf("%s\n", arg[0]); return 0; mhorsfall@tworivers:~$ gcc uh.c If I turn on -Wwrite-strings, we get some info that seems to verify my theory: mhorsfall@tworivers:~$ gcc -Wwrite-strings uh.c Likewise for the test code in the bug: mhorsfall@tworivers:~$ cc -Wwrite-strings -o break break.c -- Matthew Horsfall (alh |
From @LeontOn Sun, Dec 14, 2014 at 2:15 AM, Matthew Horsfall (alh) <wolfsage@gmail.com>
arg[0] is a non-const pointer to a value that should be non-const but isn't
char *arg[] = { argv[0], "-e", ""}; would be a pretty good start probably. Possibly we should update perlembed Leon |
From perlbug@daveola.comYes, this is the reason, a strdup takes the segfault away and all is right in the world. I can use a non-const string in my code (such as through strdup), but one could argue that either the docs need to specify this, the code needs to require a non-const string, or else the perl code should strdup in perl_parse. -- |
From zefram@fysh.orgIn addition to the string constant writability issue, the requestor's I've documented the need for writable argv strings in commit -zefram |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#44129 (status was 'resolved')
Searchable as RT44129$
The text was updated successfully, but these errors were encountered: