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

Segfault in program mingling tie and select #6276

Closed
p5pRT opened this issue Feb 5, 2003 · 4 comments
Closed

Segfault in program mingling tie and select #6276

p5pRT opened this issue Feb 5, 2003 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 5, 2003

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

Searchable as RT20727$

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2003

From gregor@focusresearch.com

Created by gregor@focusresearch.com

The program below segfaults. While I would not be surprised that
it doesn't behave well, segfaulting is a more severe misbehaviour
than I would have expected.

I was exploring the possiblity of a module that made select()
into a variable to be frobbed rather than a builtin sub to be
called. I do not assert that the program below is a correct
implementation of that idea, only that it segfaults.

#!/usr/bin/perl -w
#
# tie-segfault.pl
#
# 2001-09-11​: Genesis.
#
# Copyright (C) 2001-2003 Gregor N. Purdy. All rights reserved.
# This program is free software. It is subject to the same license as Perl.
#

use strict;

package File​::select;

sub TIESCALAR
{
  my $class = shift; my $self = select();
  return bless \$self, $class
}

sub FETCH { return select(); }
sub STORE { my $self = shift; select(shift); return select(); }

package main;

use vars qw($SELECT); tie $SELECT, 'File​::select';

$SELECT = *STDERR; # Commenting out this line stops segfault
print STDOUT $SELECT, "\n"; # Commenting out this (typo) line stops segfault
#print $SELECT "Howdy (on STDERR)\n"; # This is what the above should have been.
{ local $SELECT = *STDOUT; }

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.8.0:

Configured by bhcompile at Sun Sep  1 23:55:07 EDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.18-11smp, archname=i386-linux-thread-multi
    uname='linux daffy.perf.redhat.com 2.4.18-11smp #1 smp thu aug 15 06:41:59 edt 2002 i686 i686 i386 gnulinux '
    config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -march=i386 -mcpu=i686',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/include/gdbm'
    ccversion='', gccversion='3.2 20020822 (Red Hat Linux Rawhide 3.2-5)', 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='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=/lib/libc-2.2.92.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.2.92'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.0:
    /home/gregor/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
    /home/gregor/lib/perl5/site_perl/5.8.0
    /home/gregor/lib/perl5/site_perl/5.6.1
    /home/gregor/lib/perl5/site_perl
    /usr/lib/perl5/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl/5.6.1
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.0
    /usr/lib/perl5/vendor_perl/5.6.1
    /usr/lib/perl5/vendor_perl
    .


Environment for perl v5.8.0:
    HOME=/home/gregor
    LANG=en_US.iso885915
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/src/xml-xalan/c/lib:/usr/local/src/Sablot-0.44/lib
    LOGDIR (unset)
    PATH=.:/home/gregor/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/java/jdk1.3.1/bin:/usr/lib/ICAClient:/opt/ant/bin:/home/gregor/bin:.
    PERL5LIB=/home/gregor/lib/perl5/site_perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 13, 2003

From enache@rdslink.ro

On Thu, Mar 13, 2003 at 12​:54​:38PM +0100, Rafael Garcia-Suarez wrote​:

Fergal Daly <fergal@​esatclear.ie> wrote​:

Yes, Perl's syntax error stuff sucks, it's often completely wrong about the
line number, especially when a big if/else is involved. I suspect it's a big
job to fix that although, I have no idea how to go about it,

Use another parser generator than yacc ?

if if .. else line-numbers problem isn't the parser's fault anyway.
Perl will print the correct line number in something like

if ($p) {
;
} elsif ( hi! I'm a syntax error) {
;
}

but not in

if ($p) {
;
} elsif ( die "dying" ) {
;
}

That's because Perl keeps the line numbers only in STATEOP's.
I see no other solution than bloating the produced code with
nextstates - just for that.
That would be really stupid.
And even if every elsif ( .. ) will become elsif ( { .. } )
some people will say it still sucks and give examples​:

1,
2,
3,
warn "add three lines ";

Regards
Adi

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2010

From @iabyn

Now fixed by commit 099be4f
in branch davem/post-5.12, which should be merged back into blead
once 5.12 has been released, and thus appear in 5.13 onwards.

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2010

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

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