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

Anonymous subroutine deallocation bug #982

Closed
p5pRT opened this issue Dec 21, 1999 · 2 comments
Closed

Anonymous subroutine deallocation bug #982

p5pRT opened this issue Dec 21, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 21, 1999

Migrated from rt.perl.org#1930 (status was 'resolved')

Searchable as RT1930$

@p5pRT
Copy link
Author

p5pRT commented Dec 21, 1999

From kev@primenet.com

-----------------------------------------------------------------
Hi,

I'm using Perl as an extension language for my favorite editor (and
have written much of the extension module myself). I have some
methods (called from perl) for registering and unregistering
callbacks. I am seeing memory corruption when I do the callback
deregistration within the same anonymous sub that was previously
registered. I first thought the bug was my problem - my understanding
of perl's guts is woefully incomplete - but I've been able to
reproduce the problem in a standalone program.

The program is below. It'll core dump (SIGSEGV) for me on linux/x86
using perl 5.00503 and 5.00404. I'm seeing the problem with both
a hand built version and with the prebuilt perl distribution that
comes with Red Hat 6.0. I could not reproduce the problem on Solaris,
but it could be that Solaris has a more forgiving malloc().

Please let me know if I can provide any further information.

Kevin

--- anontest ---
#!/usr/local/bin/perl -w

#use Devel​::Peek 'Dump';

my @​a;

testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};

sub testit {
  my $hello = "Hello";
  seta(sub {
  my ($a, $b, $c) = g(1,2,3);
  #Dump($a[1]);
  if (foo()) {
  seta(7);
  }
  g($a, $b, $c);
  print "Leaving the anonymous sub​: $hello\n";
  })
}

sub seta {
  $a[1] = $_[0];
}

sub foo {
  1;
}

sub g {
  @​_;
}
--- end anontest ---

Perl Info


Site configuration information for perl 5.00503:

Configured by kev at Mon Dec 20 00:24:01 MST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.12, archname=i686-linux
    uname='linux saguaro.lan 2.2.12 #1 fri aug 27 22:56:02 mst 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O2 -g', gccversion=cygnus-2.96 19991102
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include -DDEBUGGING'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include -DDEBUGGING'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, 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 5.00503:
    /usr/local/lib/perl5/5.00503/i686-linux
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/i686-linux
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/home/kev
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/local/netscape:/usr/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/kev/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 2, 2000

From @gsar

On Tue, 21 Dec 1999 15​:23​:38 MST, Kevin Buettner wrote​:

The program is below. It'll core dump (SIGSEGV) for me on linux/x86
using perl 5.00503 and 5.00404. I'm seeing the problem with both
a hand built version and with the prebuilt perl distribution that
comes with Red Hat 6.0. I could not reproduce the problem on Solaris,
but it could be that Solaris has a more forgiving malloc().

Please let me know if I can provide any further information.

FYI, I can't reproduce it with 5.005_63 under Linux (Debian 2.1).
Please report back if you see the problem under 5.005_63.

Sarathy
gsar@​ActiveState.com

--- anontest ---
#!/usr/local/bin/perl -w

#use Devel​::Peek 'Dump';

my @​a;

testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};
testit();
&{$a[1]};

sub testit {
my $hello = "Hello";
seta(sub {
my ($a, $b, $c) = g(1,2,3);
#Dump($a[1]);
if (foo()) {
seta(7);
}
g($a, $b, $c);
print "Leaving the anonymous sub​: $hello\n";
})
}

sub seta {
$a[1] = $_[0];
}

sub foo {
1;
}

sub g {
@​_;
}
--- end anontest ---

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