Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

perl segfaults when parsing script

by amphiplex (Monk)
on Jun 27, 2002 at 12:09 UTC ( #177680=perlquestion: print w/replies, xml ) Need Help??

amphiplex has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone of you ever noticed that perl segfaults when presented with something like:
chop string;

I think this is a bug, it certainly makes finding the error rather difficult.

--- kurt

Replies are listed 'Best First'.
Re: perl segfaults when parsing script
by Joost (Canon) on Jun 27, 2002 at 14:13 UTC
    I tried

    perl -e'chop string;'

    This segfaults with 5.6.1 / i386-linux
    but not on 5.8.0 RC2 / i686-linux-thread-multi-64all-ld

    On that machine it (rightly) gives:

    Can't modify constant item in chop at -e line 1, near "string;"

    So, yes it is a bug, and in fact it is 2 bugs: you should ofcourse be using chop $string;

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: perl segfaults when parsing script
by ariels (Curate) on Jun 27, 2002 at 12:14 UTC
    No, I've not. In fact, I just tried it with both perl 5.005_03 and perl 5.6.1 on sun4-solaris, and could get no segfault:
    <bioserv 117 [15:14] ~ >perl -e 'chop $x' <bioserv 118 [15:14] ~ >perl -e 'chop FOO' Can't modify constant item in chop at -e line 1, at EOF Execution of -e aborted due to compilation errors. <bioserv 119 [15:14] ~ >perl -e 'chop "BAR"' Can't modify constant item in chop at -e line 1, at EOF Execution of -e aborted due to compilation errors. <bioserv 120 [15:14] ~ >perl -v This is perl, version 5.005_03 built for sun4-solaris
    (Similar results for 5.6.1 dropped)

    Of course, I didn't have access to your program which segfaults perl. It could be helpful to give a minimal example which fails (= something I can try to run on my machine), as well as the output of "perl -V".

      That's interesting.
      Some cases where I get segfaults:

      ======= v5.6.1 built for i586-linux, on Linux central 2.4.18 #9 SMP
      kurt@central:~> perl -e 'chop foo' Segmentation fault

      ======= v5.6.1 built for sun4-solaris, on SunOS xxxx 5.8 Generic_108528-14 sun4u sparc SUNW,Sun-Fire
      [xxxxx: ~] perl -e 'chop foo' Modification of a read-only value attempted. Segmentation Fault (core dumped)
      ======= v5.6.1 built for alpha-dec_osf, on OSF1 xxxx V4.0 1229 alpha
      [xxxxx: ~] perl -e 'chop foo' Segmentation fault (core dumped)
      ======= v5.6.1 built for PA-RISC1.1, on HP-UX xxxx B.11.11 U 9000/800
      yyyy@xxxx:> perl -e 'chop foo' Modification of a read-only value attempted. Bus error(coredump)


      ----- kurt
        Strange...

        "perl -e 'chop foo'" dumps core on "perl, v5.6.1 built for i686-linux", "perl, v5.6.1 built for IP27-irix", and "perl, v5.6.1 built for alpha-dec_osf" (except there it also manages to print an error message "Modification of a read-only value attempted." before it dies horribly). Not on "perl, v5.6.1 built for sun4-solaris", though.

        I've compared configs, and I can't find anything distinctively different that would cause sun4-solaris to survive.

        perlbug.

Re: perl segfaults when parsing script
by demerphq (Chancellor) on Jun 27, 2002 at 13:27 UTC
    Doesnt seem to affect the AS/Win32 builds....
    D:\Development>perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 633 provided by ActiveState Corp. http://www.ActiveState. +com Built 21:33:05 Jun 17 2002 ... D:\Development>perl -e "chop string;" Can't modify constant item in chop at -e line 1, near "string;" Execution of -e aborted due to compilation errors.
    and
    E:\>perl58 -v This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) ... E:\>perl58 -e "chop string" Can't modify constant item in chop at -e line 1, at EOF Execution of -e aborted due to compilation errors.

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://177680]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2022-09-27 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (119 votes). Check out past polls.

    Notices?