Core dump with "in memory" file

F

Frank Seitz

Hi!

#!/usr/bin/perl

use strict;
use warnings;

my $stderr;
close STDERR;
open STDERR,'>',\$stderr or die;
warn "a\n";
$stderr =~ s/./xx/g;

# eof

$ ./test.pl
Segmentation fault

What is the problem?

$ perl -v
This is perl, v5.10.1 (*) built for i686-linux

Frank
--
Dipl.-Inform. Frank Seitz
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Blog: http://www.fseitz.de/blog
XING-Profil: http://www.xing.com/profile/Frank_Seitz2
 
C

C.DeRykus

Hi!

#!/usr/bin/perl

use strict;
use warnings;

my $stderr;
close STDERR;
open STDERR,'>',\$stderr or die;
warn "a\n";
$stderr =~ s/./xx/g;

# eof

$ ./test.pl
Segmentation fault

What is the problem?

$ perl -v
This is perl, v5.10.1 (*) built for i686-linux

A bug? The trailing \n appears to be problematic.

Possible workaround:

$stderr =~ s/[^\n]/xx/g;

This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread
 
S

sln

Hi!

#!/usr/bin/perl

use strict;
use warnings;

my $stderr;
close STDERR;
open STDERR,'>',\$stderr or die;
warn "a\n";
$stderr =~ s/./xx/g;

# eof

$ ./test.pl
Segmentation fault

What is the problem?

$ perl -v
This is perl, v5.10.1 (*) built for i686-linux

Frank

If $stderr =~ s/./xx/sg; it seems to work.
But, obviously some independent FILE buffering going on here,
and its out of sync with the scalar buffer.
Notice, even after $stderr is cleared of 'ab', ' b'
shows back up after a FILE write:

---------------------
use strict;
use warnings;

my $stderr;
close STDERR;
open STDERR,'>',\$stderr or die;

print STDERR "ab";
print "length \$stderr = ",length($stderr), " '$stderr'\n";
print "tell (STDERR) = ", tell(STDERR),"\n";

print "\n";
$stderr = '';
print "length \$stderr = ",length($stderr), " '$stderr'\n";

print "\n";
print STDERR "ZSSS";
print "length \$stderr = ",length($stderr), " '$stderr'\n";
print "tell (STDERR) = ", tell(STDERR),"\n";

__END__


length $stderr = 2 'ab'
tell (STDERR) = 2

length $stderr = 0 ''

length $stderr = 6 ' bZSSS'
tell (STDERR) = 6

-sln
 
F

Frank Seitz

Ben said:
Quoth "C.DeRykus said:
#!/usr/bin/perl

use strict;
use warnings;

my $stderr;
close STDERR;
open STDERR,'>',\$stderr or die;
warn "a\n";
$stderr =~ s/./xx/g;

# eof

$ ./test.pl
Segmentation fault

What is the problem?

$ perl -v
This is perl, v5.10.1 (*) built for i686-linux
A bug? The trailing \n appears to be problematic.

Possible workaround:

$stderr =~ s/[^\n]/xx/g;

This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread

With 5.10.1 for i386-freebsd I can reproduce the bug without the
newline, but only if I use a one-liner:

~% perl ioscseg
~% perl -e"$(<ioscseg)"
Segmentation fault (core dumped)
~%

The crash appears to be in the same place as before, so I presume it's
just somewhat allocation-dependant.

Do you have an idea about the reason of the crash and
what I can do to reliably circumvent the bug?

Frank
--
Dipl.-Inform. Frank Seitz
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Blog: http://www.fseitz.de/blog
XING-Profil: http://www.xing.com/profile/Frank_Seitz2
 
P

Peter J. Holzer

It's a bug in perl, but it appears to have been fixed in blead. The fix
will be in 5.10.0, and probably in 5.10.2 if there ever is one
5.12.0?

hp
 

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top