For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > April 2005 > Perl regex weirdness and memory corruption?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl regex weirdness and memory corruption?
svetlana.strunjas@gmail.com

2005-04-27, 3:58 pm

I'm having a problem with Perl 5.8.0 on Linux and a regular expression
that should work. I think there is memory corruption going on
somewhere

>From the debugger:

print $safewps;
gives me:
entity#n#1

print $safewps =~ /^([^\s])/;
gives me back 'e' which is expected.

However, print $safewps =~ /^([^\s]*)/;
gives me back nothing.

Moreoever, if I assign $foo = "entity#n#1" and then try the regex's on
$foo, they work as expected. (The first one returns 'e', and the
second one returns 'entity#n#1').
Even stranger, if I try print ($foo eq $safewps) I get back 1, so they
are equal. The length of $foo and $safewps are both equal to 10, so
there are no control or space characters in there. Also, $safewps =~
/^([^\f\t\r\r ]*)/ works.


How can I debug this problem? If it's a memory error, how do I find
it?

Thank you,

~Svetlana

Gunnar Hjalmarsson

2005-04-27, 3:58 pm

svetlana.strunjas@gmail.com wrote:
> I'm having a problem with Perl 5.8.0 on Linux and a regular expression
> that should work. I think there is memory corruption going on
> somewhere
>
> print $safewps;
> gives me:
> entity#n#1
>
> print $safewps =~ /^([^\s])/;
> gives me back 'e' which is expected.
>
> However, print $safewps =~ /^([^\s]*)/;
> gives me back nothing.


Not surprisingly, it works for me.

> How can I debug this problem?


Are you using strictures and warnings?

If you want help here, please post a short but *complete* program that
gives the claimed result.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
svetlana.strunjas@gmail.com

2005-04-27, 3:58 pm

I'll try to create a complete program example -- right now there are a
lot of dependencies and the code would be too large to post.

However, I did turn on all the strictures & warnings -- and tainting.
When I turned on taint checks with -T, the program worked fine!!
Without the taint checks, the program behaves strangely (as described
in my post above).

Before I post the source, does anyone have a inkling why a program
would behave differently with taint checks vs. without taint checks?
This seems like one of those memory corruption Heisenbugs to me....

Thanks in advance,

~Svetlana

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com