develooper Front page | perl.perl5.porters | Postings from May 2002

Linux glibc 2.2.90 issue; likely from readonly stdio mmap

Thread Next
From:
Chip Turner
Date:
May 28, 2002 15:46
Subject:
Linux glibc 2.2.90 issue; likely from readonly stdio mmap
Message ID:
vzk661799i1.fsf@minbar.devel.redhat.com

This is a bit of an involved report because of the oddities of the
environment I am building in.  Basically unless d_stdstdio is
forcefully undefined, a segfault results during build on the first use
of miniperl.  The stack trace is below.  The problem seems to stem
from glibc 2.2.90 and perl seeming to want to examine the internals of
the FILE structures.  Undefining d_stdstdio results in the segfault
below going away, but then causes xsubpp to output odd lines like
'#line #line #line' instead of the more proper '#line DynaLoader.xs
171" etc.  These problems don't occur when an older glibc is used.  I
suspect the xsubpp errors are caused by the stdio changes.  These
errors occur running the 16824 snapshot.  Configure args are below the
dump.

Anyone have any idea what's going on?  Why is perl digging inside the
supposedly opaque FILE structures?  My suspicion is that this is the
cause of the problem because of possible changes in glibc from 2.2.5
to 2.2.90 (prerelease 2.3 glibc).  There was a change to readonly
stdio streams that I think is the culprit, as it would explain why
writing to a valid area of memory generates a fault:

* Read-only stdio streams now use mmap to speed up operation but eliminating
  copying and buffer underflows.  Implemented by Ulrich Drepper.

What's the best way around this?  It will likely be a bigger issue as
glibc 2.3 makes its way further into the wild.

Chip

[root@porky perl-5.7.3]# gdb miniperl
GNU gdb Red Hat Linux (5.1.92-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) r -Ilib configpm configpm.tmp
Starting program: /usr/src/redhat/BUILD/perl-5.7.3/miniperl -Ilib configpm configpm.tmp
[New Thread 1024 (LWP 3490)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 3490)]
0x420752fd in memmove () from /lib/i686/libc.so.6
(gdb) bt
#0  0x420752fd in memmove () from /lib/i686/libc.so.6
#1  0x0813d02b in PerlIOStdio_unread (my_perl=0x8173008, f=0x818545c, vbuf=0xbfffd803, count=1) at perlio.c:2653
#2  0x0813ae5c in Perl_PerlIO_unread (my_perl=0x8173008, f=0x818545c, vbuf=0xbfffd803, count=1) at perlio.c:1402
#3  0x0813fcd9 in PerlIO_ungetc (f=0x818545c, ch=84) at perlio.c:4288
#4  0x080cfb0d in Perl_sv_gets (my_perl=0x8173008, sv=0x81b9d9c, fp=0x818545c, append=0) at sv.c:5724
#5  0x080be908 in Perl_do_readline (my_perl=0x8173008) at pp_hot.c:1540
#6  0x080b9f53 in Perl_pp_readline (my_perl=0x8173008) at pp_hot.c:225
#7  0x080b8f33 in Perl_runops_standard (my_perl=0x8173008) at run.c:23
#8  0x0806680b in S_run_body (my_perl=0x8173008, oldscope=1) at perl.c:1677
#9  0x08066375 in perl_run (my_perl=0x8173008) at perl.c:1598
#10 0x0804cdcb in main (argc=4, argv=0xbffffb24, env=0xbffffb38) at miniperlmain.c:85
#11 0x420164a4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) frame 1
#1  0x0813d02b in PerlIOStdio_unread (my_perl=0x8173008, f=0x818545c, vbuf=0xbfffd803, count=1) at perlio.c:2653
2653                Move(buf-avail,ptr,avail,STDCHAR);
(gdb) info local
buf = 0xbfffd804 "%/1€Œiso8859-15ð\t\027\b\230%/1€Žiso8859-15øÿ¿\r%/1€Œiso8859-15û\f\b\\T\030\bT"
base = 0x400f7000 "This file contains a description of all the shell variables whose value is\ndetermined by the Configure script.  Variables intended for use in C\nprograms (e.g. I_UNISTD) are already described in config"....
cnt = 175788
ptr = 0x400f7000 "This file contains a description of all the shell variables whose value is\ndetermined by the Configure script.  Variables intended for use in C\nprograms (e.g. I_UNISTD) are already described in config"...
avail = 1
unread = 0
s = (struct _IO_FILE *) 0x81b7b70
(gdb) l
2648            if (avail > 0) {
2649                if (avail > count) {
2650                    avail = count;
2651                }
2652                ptr -= avail;
2653                Move(buf-avail,ptr,avail,STDCHAR);
2654                count -= avail;
2655                unread += avail;
2656                PerlIO_set_ptrcnt(f,ptr,cnt+avail);
2657                if (PerlSIO_feof(s) && unread >= 0)
(gdb) 


config_arg10='-Darchname=i386-linux'
config_arg11='-Dvendorprefix=/usr'
config_arg12='-Dsiteprefix=/usr'
config_arg13='-Dusethreads'
config_arg14='-Duseithreads'
config_arg15='-Duselargefiles'
config_arg16='-Dd_dosuid'
config_arg17='-Dd_semctl_semun'
config_arg18='-Di_db'
config_arg19='-Ui_ndbm'
config_arg2='-Doptimize=-g -march=i386 -mcpu=i686 -fPIC'
config_arg20='-Di_gdbm'
config_arg21='-Di_shadow'
config_arg22='-Di_syslog'
config_arg23='-Dman3ext=3pm'
config_arg24='-Dinstallusrbinperl'
config_arg25='-Ubincompat5005'
config_arg26='-Uversiononly'
config_arg3='-Dmyhostname=localhost'
config_arg4='-Dperladmin=root@localhost'
config_arg5='-Dcc=gcc'
config_arg6='-Dcf_by=Red Hat, Inc.'
config_arg7='-Dcccdlflags=-fPIC'
config_arg8='-Dinstallprefix=/var/tmp/perl-root/usr'
config_arg9='-Dprefix=/usr'

Chip

-- 
Chip Turner                   cturner@redhat.com
                              Red Hat Network

Thread Next


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