develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24225] [5.8.1] segfault in binmode STDOUT, ':stdio'; print 1

From:
Slaven Rezic
Date:
October 19, 2003 08:59
Subject:
Re: [perl #24225] [5.8.1] segfault in binmode STDOUT, ':stdio'; print 1
Message ID:
871xt9te7g.fsf@vran.herceg.de
Elizabeth Mattijsen <liz@dijkmat.nl> writes:

> At 21:30 +0000 10/15/03, Stas Bekman (via RT) wrote:
> >% perl-5.8.1 -wle "binmode STDOUT, ':stdio'; print 1"
> >Segmentation fault
> 
> I can NOT reproduce this on Linux, nor Mac OS X, with either 
> threaded, unthreaded or debug versions of Perl.
> 
> Linux bibi 2.4.10-4GB #1 Fri Sep 28 17:20:21 GMT 2001 i686 unknown
> 
> Darwin Lyzibook 6.8 Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 
> PDT 2003; root:xnu/xnu-344.49.obj~2/RELEASE_PPC  Power Macintosh 
> powerpc
> 
> 
> Maybe this is a Locale setting dependent phenomenon?
> 

It's reproducible if calling with PERLIO=perlio. This patch seems to
fix it:

--- bleedperl/perlio.c	Wed Sep 24 20:47:51 2003
+++ bleedperl2/perlio.c	Sun Oct 19 17:51:10 2003
@@ -2613,8 +2613,10 @@ char *
 PerlIOStdio_mode(const char *mode, char *tmode)
 {
     char *ret = tmode;
-    while (*mode) {
-	*tmode++ = *mode++;
+    if (mode) {
+	while (*mode) {
+	    *tmode++ = *mode++;
+	}
     }
 #if defined(PERLIO_USING_CRLF) || defined(__CYGWIN__)
     *tmode++ = 'b';


-- 
Slaven Rezic - slaven@rezic.de

    tktimex - project time manager
    http://sourceforge.net/projects/ptktools/



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About