develooper Front page | perl.perl5.porters | Postings from January 2008

Re: [perl #50256] segfault on perl -e 'split //, unpack "(B)*","ab"'

Thread Previous
From:
H.Merijn Brand
Date:
January 26, 2008 02:36
Subject:
Re: [perl #50256] segfault on perl -e 'split //, unpack "(B)*","ab"'
Message ID:
20080126113548.099921f1@pc09.procura.nl
On Sat, 26 Jan 2008 05:27:05 +0000, "Ævar Arnfjörð Bjarmason"
<avarab@gmail.com> wrote:

> This looks to my untrained eye like something unpack is causing its
> return value to be a damaged PMOP.
> 
>     $ ./perl -le 'split //, unpack("(B)*", "ab")'
>     Segmentation fault
>     $ ./perl -le 'my $s = unpack("(B)*", "ab"); split //, $s'
>     $ ./perl -le 'my $s = unpack("(B)*", "ab"); unpack "(a)*", $s'
>     $ ./perl -le 'unpack "(a)*", unpack("(B)*", "ab");'
>     Invalid type '0' in unpack at -e line 1.
> 
> This will actually segfault at different times in Perl_pp_split
> depending on whether you compile with -DDEBUGGING or not, at least on
> my system.
> :
> (btw how does one build perl without -DDEBUGGING properly? I did
> `./Configure -Dcc='ccache gcc' -Dld=gcc -Doptimize=-ggdb3 -d -e' which
> put -DDEBUGGING in my makefile, presumably because it picked up
> -ggdb3, I edited the definition out by hand)

I hope I was explainatory enough in my addition to INSTALL when I added
support for -DDEBUGGING to Configure:

      Building a debugging perl

       You can run perl scripts under the perl debugger at any time with perl
       −d your_script.  If, however, you want to debug perl itself, you
       probably want to have support for perl internal debugging code
       (activated by adding −DDEBUGGING to ccflags), and/or support for the
       system debugger by adding −g to the optimisation flags. For that, use
       the parameter:

               sh Configure −DDEBUGGING

       or

               sh Configure −DDEBUGGING=<mode>

       For a more eye appealing call, −DEBUGGING is defined to be an alias for
       −DDEBUGGING. For both, the −U calls are also supported, in order to be
       able to overrule the hints or Policy.sh settings.

       Here are the DEBUGGING modes:

       −DDEBUGGING
       −DEBUGGING
       −DEBUGGING=both
           Sets both −DDEBUGGING in the ccflags, and adds −g to optimize.

           You can actually specify −g and −DDEBUGGING independently (see
           below), but usually it’s convenient to have both.

       −DEBUGGING=−g
       −Doptimize=−g
           Adds −g to optimize, but does not set −DDEBUGGING.

           (Note:  Your system may actually require something like cc −g2.
           Check your man pages for cc(1) and also any hint file for your
           system.)

       −DEBUGGING=none
       −UDEBUGGING
           Removes −g from optimize, and −DDEBUGGING from ccflags.

       If you are using a shared libperl, see the warnings about multiple
       versions of perl under "Building a shared Perl library".

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About