# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #37119]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37119 >


This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.35 running under perl v5.8.5.


-----------------------------------------------------------------
[Please enter your report here]

This is definitely platform dependent - I can reproduce this on x86 Linux,
but not x86 FreeBSD or OS X.

fork and __DATA__ don't mix. I don't think that we document this anywhere.
I don't know if we should, given the amount of documentation, but it is a
subtle gotcha, and it had never occurred to me.

The basic problem is with modules that lazily read from the DATA file
handle, particularly if they read from another package's DATA file handle
lazily, and on demand. DATA is implemented by the Perl 5 compiler leaving
the program's file handle open if it encounters the __DATA__ token. All is
fine and dandy, until you fork. At which point both processes now have a
(buffered) DATA file handle pointing to the same kernel file descriptor.
When one reads from DATA, the other's DATA handle moves. Underneath it.


SelfLoader breaks.

$ cat Demo.pm
#!perl -w

package Demo;
sub import {};
use SelfLoader;
@ISA = 'SelfLoader';

1;
__DATA__
sub hash {
    print "pig-pen: $_[0]\n";
}

$ cat demo.pl
#!perl -w
use strict;

use Demo;

my $pid = fork();
sleep 2 if $pid;
Demo::hash ($pid);

$ perl demo.pl
pig-pen: 0
Undefined subroutine Demo::hash at demo.pl line 8


I'm not sure if/how we can fix SelfLoader. I'm not sure where we should
document this gotcha with DATA.

Nicholas Clark

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.5:

Configured by root at Mon Oct 18 17:51:35 BST 2004.

Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
  Platform:
    osname=linux, osvers=2.4.21-4.elsmp, archname=i686-linux
    uname='linux switch.work.fotango.com 2.4.21-4.elsmp #1 smp fri oct 3 
17:52:56 edt 2003 i686 i686 i386 gnulinux '
    config_args='-Dprefix=/usr/local/perl-5.8.5 -Uinstallusrbinperl -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -I/usr/include/gdbm'
    ccversion='', gccversion='3.2.3 20030502 (Red Hat Linux 3.2.3-20)', 
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.5:
    /usr/local/perl-5.8.5/lib/5.8.5/i686-linux
    /usr/local/perl-5.8.5/lib/5.8.5
    /usr/local/perl-5.8.5/lib/site_perl/5.8.5/i686-linux
    /usr/local/perl-5.8.5/lib/site_perl/5.8.5
    /usr/local/perl-5.8.5/lib/site_perl
    .

---
Environment for perl v5.8.5:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/home/nick/bin:/usr/kerberos/bin:/usr/lib/ccache/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

Reply via email to