Bug in perl v5.8.5 Built for sun4-solaris. Any patch availabale?

Discussion in 'Perl Misc' started by Gancy, Jan 27, 2005.

  1. Gancy

    Gancy Guest

    Hello All,

    Today I have posted a question regrdaing a core dump issue. I did more
    investigation on this and I found some more information.

    1. I have a HPUX 11i box and the perl version and other information is
    as follows:
    *******************************************************
    This is perl, v5.6.1 built for PA-RISC1.1-thread-multi
    (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:04:57 Jun 17 2002


    Perl may be copied only under the terms of either the Artistic License
    or the
    GNU General Public License, which may be found in the Perl 5 source
    kit.
    ******************************************************

    With this version of perl I DONT see core dump problem. But with the
    perl which I have on my SunOS box, I do see core dump.

    *******************************************************
    This is perl, v5.8.5 built for sun4-solaris

    Copyright 1987-2004, Larry Wall

    Perl may be copied only under the terms of either the Artistic License
    or the
    GNU General Public License, which may be found in the Perl 5 source
    kit.

    Complete documentation for Perl, including FAQ lists, should be found
    on
    this system using `man perl' or `perldoc perl'. If you have access to
    the
    Internet, point your browser at http://www.perl.com/, the Perl Home
    Page.
    ********************************************************

    Here is the stack trace:

    [24376] S_regmatch(0x0, 0x128468, 0x1, 0x117400, 0x11a000,
    0xffffffff), at 0xd4934
    [24377] S_regmatch(0x0, 0x128460, 0x0, 0x117400, 0x11a000,
    0xffffffff), at 0xd4934
    [24378] S_regmatch(0x0, 0x128450, 0x0, 0x117400, 0x11a000,
    0xffffffff), at 0xd4934
    [24379] S_regmatch(0x0, 0x128438, 0x0, 0x117400, 0x11a000,
    0xffffffff), at 0xd4714
    [24380] S_regtry(0x1283c8, 0x16288b, 0x12e531, 0x18cf56, 0x18cf57,
    0x1627ef), at 0xd0a78
    [24381] Perl_regexec_flags(0x1283c8, 0x1627ef, 0x18cf55, 0x161da0,
    0x0, 0x16288b), at 0xd0554
    [24382] Perl_pp_match(0x1283c8, 0x12d878, 0x100, 0x12d878, 0x18cf65,
    0x13), at 0x819e4
    [24383] Perl_runops_standard(0x117400, 0x1223e0, 0x127420, 0x0,
    0x11ff94, 0x0), at 0x7de70
    [24384] S_run_body(0x1, 0x117c00, 0x117c00, 0x0, 0xffbefa4c, 0x3), at
    0x28490
    [24385] perl_run(0x0, 0xfffffffc, 0x3, 0xffbefa3c, 0x0, 0x0), at
    0x280c0
    [24386] main(0x3, 0xffbefa3c, 0xffbefa4c, 0x1176a8, 0x0, 0x0), at
    0x24e34

    Has anyone faced similar problem?? If any patch is available then
    please let me know.

    ******************************
    My previous question was....

    Here is the snipet of the perl script, I have perl version v5.8.5 built
    for sun4-solaris. I have run this script on thousands of 'c','C++'
    headers and source files. Runs smoothly as my new ESTEEM car. But i
    have one surce file toke.c in my test case. soon this scripts hits this
    file at it dumps. I have tried and still trying to debug, but still no
    solutions. If anybody can help me with this would be of great
    appreciation. I can uploaded source file (toke.c) as well as core file
    frames(core), if needed.


    #!/usr/bin/perl


    $np = qr{
    \(
    (?:
    (?>[^()]+ )
    |
    (??{ $np })
    )*
    \)


    }x;


    $funpat = qr/((\W)?(\*?\*?\w+)\s*($np))/;
    my $temp;


    open (FILE, "toke.c") || die "Cannot open file";


    while($temp = <FILE>)
    {
    $tstring.=$temp;


    }


    close FILE;


    get_fn_call($tstring);


    sub get_fn_call($){
    my ($cur_str) = @_;
    while( $cur_str =~ m/$funpat/g )
    {
    $4 =~ /^\(((.*\n*.*)*)\)$/;
    get_fn_call($1);


    }
    }

    Thanks
    -Ganesh
    Gancy, Jan 27, 2005
    #1
    1. Advertising

  2. Gancy

    Anno Siegel Guest

    Gancy <> wrote in comp.lang.perl.misc:
    > Hello All,
    >
    > Today I have posted a question regrdaing a core dump issue. I did more
    > investigation on this and I found some more information.


    [snip]

    > Has anyone faced similar problem?? If any patch is available then
    > please let me know.
    >
    > ******************************
    > My previous question was....
    >
    > Here is the snipet of the perl script, I have perl version v5.8.5 built
    > for sun4-solaris. I have run this script on thousands of 'c','C++'
    > headers and source files. Runs smoothly as my new ESTEEM car. But i
    > have one surce file toke.c in my test case. soon this scripts hits this
    > file at it dumps. I have tried and still trying to debug, but still no
    > solutions. If anybody can help me with this would be of great
    > appreciation. I can uploaded source file (toke.c) as well as core file
    > frames(core), if needed.
    >
    >
    > #!/usr/bin/perl
    >
    >
    > $np = qr{
    > \(
    > (?:
    > (?>[^()]+ )
    > |
    > (??{ $np })
    > )*
    > \)
    >
    >
    > }x;
    >
    >
    > $funpat = qr/((\W)?(\*?\*?\w+)\s*($np))/;
    > my $temp;
    >
    >
    > open (FILE, "toke.c") || die "Cannot open file";
    >
    >
    > while($temp = <FILE>)
    > {
    > $tstring.=$temp;
    >
    >
    > }
    >
    >
    > close FILE;
    >
    >
    > get_fn_call($tstring);
    >
    >
    > sub get_fn_call($){
    > my ($cur_str) = @_;
    > while( $cur_str =~ m/$funpat/g )
    > {
    > $4 =~ /^\(((.*\n*.*)*)\)$/;
    > get_fn_call($1);
    >
    >
    > }
    > }


    That's a horrible little program.

    Recursive regexes are fun, but should probably not be used in production
    code. In particular, note that the /(??{ code })/ construct is still
    experimental, which means that bugs must be expected.

    The regex recursion seems to go out of control on toke.c. You can watch this
    after the following modification to the definitions of $np and $funpat:

    our $count;
    my $np;
    $np = qr{
    \(
    (?:
    (?>[^()]+ )
    |
    (??{ $count ++; print "recurs $count\n"; $np })
    )*
    \)
    }x;

    use re 'eval';
    my $funpat = qr/(?{ $count = 0 })((\W)?(\*?\*?\w+)\s*($np))/;

    With other files, the count in recurs stays below 10 or so. With toke.c,
    it counts up until something breaks. That looks like an error in the
    definition of $np (I'm not debugging this any further). The bug in
    Perl is that it doesn't recognize deep regex recursion. That could
    presumably be demonstrated by a simpler program.

    If you want to file a bug, write that simple demonstration. If you want
    your program to run on toke.c, fix the regex, it's wrong.

    If you want your program to be solid code, rewrite it from scratch,
    probably based on Text::Balanced.

    Anno
    Anno Siegel, Jan 27, 2005
    #2
    1. Advertising

  3. Gancy

    Anno Siegel Guest

    Gancy <> wrote in comp.lang.perl.misc:
    > Hello All,
    >
    > Today I have posted a question regrdaing a core dump issue. I did more
    > investigation on this and I found some more information.


    [snip]

    > Has anyone faced similar problem?? If any patch is available then
    > please let me know.
    >
    > ******************************
    > My previous question was....
    >
    > Here is the snipet of the perl script, I have perl version v5.8.5 built
    > for sun4-solaris. I have run this script on thousands of 'c','C++'
    > headers and source files. Runs smoothly as my new ESTEEM car. But i
    > have one surce file toke.c in my test case. soon this scripts hits this
    > file at it dumps. I have tried and still trying to debug, but still no
    > solutions. If anybody can help me with this would be of great
    > appreciation. I can uploaded source file (toke.c) as well as core file
    > frames(core), if needed.
    >
    >
    > #!/usr/bin/perl
    >
    >
    > $np = qr{
    > \(
    > (?:
    > (?>[^()]+ )
    > |
    > (??{ $np })
    > )*
    > \)
    >
    >
    > }x;
    >
    >
    > $funpat = qr/((\W)?(\*?\*?\w+)\s*($np))/;
    > my $temp;
    >
    >
    > open (FILE, "toke.c") || die "Cannot open file";
    >
    >
    > while($temp = <FILE>)
    > {
    > $tstring.=$temp;
    >
    >
    > }
    >
    >
    > close FILE;
    >
    >
    > get_fn_call($tstring);
    >
    >
    > sub get_fn_call($){
    > my ($cur_str) = @_;
    > while( $cur_str =~ m/$funpat/g )
    > {
    > $4 =~ /^\(((.*\n*.*)*)\)$/;
    > get_fn_call($1);
    >
    >
    > }
    > }


    That's a horrible little program. Whoever wrote it must have been high
    on recursion. The first time I saw it, I just averted my eyes.

    Recursive regexes are fun but should probably not be used in production
    code. In particular note that the /(??{ code })/ construct is still
    experimental, which means that bugs must be expected.

    The regex recursion seems to go out of control on toke.c. You can watch this
    after the following modification to the definitions of $np and $funpat:

    our $count;
    my $np;
    $np = qr{
    \(
    (?:
    (?>[^()]+ )
    |
    (??{ $count ++; print "recurs $count\n"; $np })
    )*
    \)
    }x;

    use re 'eval';
    my $funpat = qr/(?{ $count = 0 })((\W)?(\*?\*?\w+)\s*($np))/;

    With other files, the count in recurs stays below 10 or so. With toke.c,
    it counts up until something breaks. That looks like an error in the
    definition of $np (I'm not debugging this any further). The bug in
    Perl is that it doesn't recognize deep regex recursion. That could
    presumably be demonstrated by a simpler program.

    If you want to file a bug, write that simple demonstration. If you want
    your program to run on toke.c, fix the regex, it's wrong.

    If you want your program to be solid code, rewrite it from scratch,
    probably based on Text::Balanced.

    Anno
    Anno Siegel, Jan 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kikoz
    Replies:
    6
    Views:
    376
    Indentix, Inc.
    Jul 27, 2004
  2. George Sakkis
    Replies:
    3
    Views:
    344
  3. Zeno Davatz
    Replies:
    4
    Views:
    159
    Zeno Davatz
    Jan 10, 2011
  4. daveo
    Replies:
    0
    Views:
    138
    daveo
    Mar 21, 2005
  5. ramanmu
    Replies:
    1
    Views:
    194
    A. Sinan Unur
    May 16, 2005
Loading...

Share This Page