Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'write' on closed filehandle dumps core at end of page #5907

Closed
p5pRT opened this issue Sep 10, 2002 · 18 comments
Closed

'write' on closed filehandle dumps core at end of page #5907

p5pRT opened this issue Sep 10, 2002 · 18 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 10, 2002

Migrated from rt.perl.org#17099 (status was 'open')

Searchable as RT17099$

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @mjdominus

Created by @mjdominus

This program dumps core.

  #!/usr/bin/perl

  while (1) {
  write REPORT;
  }

  format REPORT_TOP =
  T
  .

  format REPORT =
  X
  .

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by root at Sat Dec 29 11:54:59 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.2-2, archname=i586-linux
    uname='linux plover.com 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown '
    config_args='-des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', 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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.1:
    /usr/local/lib/perl5/5.6.1/i586-linux
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.1:
    HOME=/home/mjd
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11R6:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @Tux

On Tue 10 Sep 2002 05​:38, Mark-Jason Dominus (via RT) <perlbug@​perl.org> wrote​:

# New Ticket Created by Mark-Jason Dominus
# Please include the string​: [perl #17099]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt2/Ticket/Display.html?id=17099 >

This is a bug report for perl from mjd@​plover.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.

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

This program dumps core.

  \#\!/usr/bin/perl


  while \(1\) \{
    write REPORT;
  \}

  format REPORT\_TOP =
  T
  \.

  format REPORT =
  X
  \.

l1​:/tmp 112 > cat xx.pl
#!/usr/bin/perl

use strict;
use warnings;

while (1) {
  write REPORT;
  }

format REPORT_TOP =
T
.

format REPORT =
X
.
l1​:/tmp 113 > perl xx.pl | & head
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
Exit 141
l1​:/tmp 114 > env PERLIO=perlio !!
env PERLIO=perlio perl xx.pl | & head
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
write() on unopened filehandle REPORT at xx.pl line 7.
Exit 141
l1​:/tmp 115 >

I also waited for over 10 minutes for a core dump without use warnings and
without use strict, but none happened

HP-UX 11.00, perl-5.8.0 + defined-od patches

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11. Smoking perl CORE​: smokers@​perl.org
http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org
send smoke reports to​: smokers-reports@​perl.org, QA​: http​://qa.perl.org

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @mjdominus

I also waited for over 10 minutes for a core dump without use warnings and
without use strict, but none happened

Great; let's mark it as resolved.

I thought maybe I had reported the same bug before, but I wasn't sure.

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @Tux

On Tue 10 Sep 2002 12​:34, Mark-Jason Dominus <mjd@​plover.com> wrote​:

I also waited for over 10 minutes for a core dump without use warnings and
without use strict, but none happened

Great; let's mark it as resolved.

I thought maybe I had reported the same bug before, but I wasn't sure.

What perl and what system did you use. I can check others.

threading?
64bit?

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11. Smoking perl CORE​: smokers@​perl.org
http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org
send smoke reports to​: smokers-reports@​perl.org, QA​: http​://qa.perl.org

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @lizmat

At 12​:42 PM 9/10/02 +0200, H.Merijn Brand wrote​:

On Tue 10 Sep 2002 12​:34, Mark-Jason Dominus <mjd@​plover.com> wrote​:

I also waited for over 10 minutes for a core dump without use
warnings and
without use strict, but none happened
Great; let's mark it as resolved.
I thought maybe I had reported the same bug before, but I wasn't sure.

Hmmm... running it here with threaded 5.8.0 under Linux, I see the process
grow at about 300K per CPU second used.

I find the process growth suspicious​: maybe at one point the growth is
tickling OS kernel memory management (swap?) problems...

Liz

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @mjdominus

Created by @mjdominus

The write() itself doesn't cause the segv; it's just silently
ignored. Rather, when you write past the end of the 'page',
Perl tries to invoke the FH_TOP format automatically, and that cuases
the segv.

I tried to fix it, but it turned out to be more complicated than I
thought. Enclosed is a patch to t/op/misc.t that installs a test case
for this bug.

--- t/op/misc.t 2000/12/10 19​:48​:23 1.1
+++ t/op/misc.t 2000/12/10 19​:51​:08 1.2
@​@​ -545,3 +545,23 @​@​
lcfirst - world
uc - WORLD
lc - world
+########
+# 20001210 mjd@​plover.com
+format REMITOUT_TOP =
+FOO
+.
+
+format REMITOUT =
+BAR
+.
+
+# This loop causes a segv in 5.6.0
+for $lineno (1..61) {
+ write REMITOUT;
+}
+
+print "It's OK!";
+EXPECT
+It's OK!
+
+

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.6.0:

Configured by mjd at Wed Sep 20 15:34:29 EDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.16, archname=i586-linux
    uname='linux plover 2.2.16 #97 fri jun 16 19:45:30 pdt 2000 i586 unknown '
    config_args='-Doptimize=-g -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/i586-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl/5.00557/i586-linux
    /usr/local/lib/perl5/site_perl/5.00557
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/mjd
    LANG (unset)
    LANGUAGE (unset)
    LC_ALL=POSIX
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2002

From @rspier

Here's the original report. (It wasn't until after I sent the new
report that I realized that the bug seemed familiar.)

......

I've added a link between the two in the system. The old one is
[perl #4893]

-R

@p5pRT
Copy link
Author

p5pRT commented Sep 26, 2002

From @hvds

Mark-Jason Dominus <mjd@​plover.com> wrote​:
:Here's the original report. (It wasn't until after I sent the new
:report that I realized that the bug seemed familiar.)
[...]
:I tried to fix it, but it turned out to be more complicated than I
:thought. Enclosed is a patch to t/op/misc.t that installs a test case
:for this bug.
:
:--- t/op/misc.t 2000/12/10 19​:48​:23 1.1
:+++ t/op/misc.t 2000/12/10 19​:51​:08 1.2

I was going to add this, but of course we don't have t/op/misc.t
any more. Since you two appear to be among the few ever to go near
formats, perhaps one of you would care to submit a t/op/format.t?

Hugo

@p5pRT
Copy link
Author

p5pRT commented Sep 26, 2002

From @Tux

On Thu 26 Sep 2002 10​:51, <hv@​crypt.org> wrote​:

Mark-Jason Dominus <mjd@​plover.com> wrote​:
:Here's the original report. (It wasn't until after I sent the new
:report that I realized that the bug seemed familiar.)
[...]
:I tried to fix it, but it turned out to be more complicated than I
:thought. Enclosed is a patch to t/op/misc.t that installs a test case
:for this bug.
:
:--- t/op/misc.t 2000/12/10 19​:48​:23 1.1
:+++ t/op/misc.t 2000/12/10 19​:51​:08 1.2

I was going to add this, but of course we don't have t/op/misc.t
any more. Since you two appear to be among the few ever to go near
formats, perhaps one of you would care to submit a t/op/format.t?

Format tests are in write.t

Hugo

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11. Smoking perl CORE​: smokers@​perl.org
http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org
send smoke reports to​: smokers-reports@​perl.org, QA​: http​://qa.perl.org

@p5pRT
Copy link
Author

p5pRT commented May 17, 2003

From @jhi

Just tested this with bleadperl and no SEGV but yes, a fast process sizze growth
(in Debian Linux), so probably not yet resolved.

@p5pRT
Copy link
Author

p5pRT commented May 17, 2003

@jhi - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 8, 2005

From @mjdominus

Apparently fixed in 5.8.0.

@p5pRT
Copy link
Author

p5pRT commented Jun 8, 2005

@mjdominus - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 8, 2005
@p5pRT
Copy link
Author

p5pRT commented Jun 8, 2005

@mjdominus - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 8, 2005

From @mjdominus

Oops, I wasn't paying attention. As Jarkko pointed out, this still
causes a very severe memory leak in 5.8.1.

@p5pRT
Copy link
Author

p5pRT commented May 27, 2012

From @jkeenan

On Mon Sep 09 20​:38​:29 2002, mjd@​plover.com wrote​:

This is a bug report for perl from mjd@​plover.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.

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

This program dumps core.

  \#\!/usr/bin/perl


  while \(1\) \{
    write REPORT;
  \}

  format REPORT\_TOP =
  T
  \.

  format REPORT =
  X
  \.

When I run this as​: perl -d 17099.pl, I get an indefinite series of
warnings​:

write() on unopened filehandle REPORT at 17099.pl line 4.

(perl 5.16.0)

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2012

From @cpansprout

On Sat May 26 18​:24​:13 2012, jkeenan wrote​:

On Mon Sep 09 20​:38​:29 2002, mjd@​plover.com wrote​:

This is a bug report for perl from mjd@​plover.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.

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

This program dumps core.

  \#\!/usr/bin/perl


  while \(1\) \{
    write REPORT;
  \}

  format REPORT\_TOP =
  T
  \.

  format REPORT =
  X
  \.

When I run this as​: perl -d 17099.pl, I get an indefinite series of
warnings​:

write() on unopened filehandle REPORT at 17099.pl line 4.

(perl 5.16.0)

That’s not suprising, as it has an explicit infinite loop. But if you
put ‘warn $$’ at the top of the program and then watch the memory usage,
you’ll see what the real bug is.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2012

From @cpansprout

On Sun Aug 05 13​:07​:33 2012, sprout wrote​:

On Sat May 26 18​:24​:13 2012, jkeenan wrote​:

On Mon Sep 09 20​:38​:29 2002, mjd@​plover.com wrote​:

This is a bug report for perl from mjd@​plover.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.

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

This program dumps core.

  \#\!/usr/bin/perl


  while \(1\) \{
    write REPORT;
  \}

  format REPORT\_TOP =
  T
  \.

  format REPORT =
  X
  \.

When I run this as​: perl -d 17099.pl, I get an indefinite series of
warnings​:

write() on unopened filehandle REPORT at 17099.pl line 4.

(perl 5.16.0)

That’s not suprising, as it has an explicit infinite loop. But if you
put ‘warn $$’ at the top of the program and then watch the memory usage,
you’ll see what the real bug is.

It’s leaking because a bad file handle causes the output to be held in
the accumulator​:

for(1..5) {
  write REPORT;
}

warn $^A =~ s'\n'\n'rug;

*REPORT = *STDOUT{IO};
write REPORT;

format REPORT =
X
.
__END__
X\nX\nX\nX\nX\n at - line 6.
X
X
X
X
X
X

Should that change? If not, I think we can mark this as not-a-bug.
That is certainly longstanding behaviour.

--

Father Chrysostomos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant