1031 Off_t 1032 Perl_do_tell(pTHX_ GV *gv) 1033 { 1034 dVAR; 1035 register IO *io = NULL; 1036 register PerlIO *fp; 1037 1038 if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) { 1039 #ifdef ULTRIX_STDIO_BOTCH 1040 if (PerlIO_eof(fp)) 1041 (void)PerlIO_seek(fp, 0L, 2); /* ultrix 1.2 wor +karound */ 1042 #endif 1043 return PerlIO_tell(fp); 1044 } 1045 if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) 1046 report_evil_fh(gv, io, PL_op->op_type); 1047 SETERRNO(EBADF,RMS_IFI); 1048 return (Off_t)-1; 1049 }
I don't see how passing NULL to do_tell (as shown in your stack trace) would cause any problems. The line where the segfault occurs in your strack trace explicitly checks if gv is NULL before using it. Could this be a compiler optimisation problem? I could confirm that if I saw the assembler code for that function on a machine where it crashes.
As an aside, I discovered that Perl will treat a number passed to tell as the name of a glob.
$ perl -MO=Concise -e'tell 1234' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 5 <1> tell[t2] vK/1 ->6 4 <1> rv2gv sK*/1 ->5 3 <#> gv[*1234] s ->4 -e syntax OK $ perl -MO=Concise -e'tell *1234' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 5 <1> tell[t2] vK/1 ->6 4 <1> rv2gv sKR/1 ->5 3 <#> gv[*1234] s ->4 -e syntax OK
(And not just when it's a constant. It's just easier to see there.)
That means the following are all equivalent:
my $fh = \*STDOUT; tell( 0+$fh );
my $fh = \*STDOUT; no strict 'refs'; tell( *{ ''.(0+$fh) } );
# Assuming STDOUT is still located at address 0x814ec28 tell( *135588904 );
In reply to Re^2: Perl segfaults: Why?
by ikegami
in thread Perl segfaults: Why?
by bv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |