开发者

Help understanding malloc error from Perl-CGI script? or Where is malloc_error_break

This is the error:

[Fri Jun 24 18:26:44 2011] [error] [client ::1] perl(3116) malloc: *** error for object 0x10082b808: incorrect checksum for freed object - object was probably modified after being freed.
[Fri Jun 24 18:26:44 2011] [error] [client ::1] *** set a breakpoint in malloc_error_break to debug
[Fri Jun 24 18:26:44 2011] [error] [client ::1] Premature end of script headers: adjsearch.cgi

First, I could attempt to debug if I knew how to apply the advice of the second line from the error_log. http://lists.apple.com/archives/Xcode-users/2008/Apr/msg00160.html talks about it in Xcode, but I'm not using Xcode...

I have no idea what this means, and would like some help understanding the following explanation, and how I can use this info to help debug.:

And after some searching, I found this:

The error means exactly what it says: you have probably modified memory after freeing it. Your code snippet doesn't show, for instance, where itr_coord was allocated, but the code where you see this error message is simply the point at which some memory operation (probably an allocation) caused the memory debugger to verify checksums of freed objects. This doesn't really tell you much about where the error of writing to freed memory actually occurred

If you'd like some more specific background let me know. Thanks a lot!

UPDATE: very bizarre, here is the problem (not solution):

elsif ($category_id eq "allverb")
     {
      if (($lines[$l] =~ /\b$verbform\b/i))
        {
        next unless ($lines[$l] =~ /\w+\((\w+)\-\d+\,\s(\w+)\-\d+\)/);
        $arg1 = $1;
        $arg2 = $2;
         #If the searchword is the 1st argument
            $goodmatch = 1;

         }
      }

There is no error if I do something like this (note added if statement):

elsif ($category_id eq "allverb")
   {
   if (($lines[$l] =~ /\b$verbform\b/i))
      {
       next unless ($lines[$l] =~ /\w+\((\w+)\-\d+\,\s(\w+)\-\d+\)/);
       $arg1 = $1;
       $arg2 = $2;

        if ($arg1 eq $verbform)
            {
              $goodmatch = 1;
            }
       }
   }

but there is again if I put if ($arg1 eq $verbform or $arg2 eq $verbform) or just separate thos开发者_如何学Goe to if statements..?

Maybe it's a memory error.... my code is written pretty inefficiently right now. Or apache error... Anytime I restrict the condition more (add more to the if statement, so less gets through) it works! How can I get around this?

VERSIONS USED:

Mac OS X 10.6.7... Perl version 5.10.0 ... Apache2? The one that comes with the Mac...


I cannot answer your question directly, but I can say that malloc errors in Perl are not common, especially in the sort of code you present here.

Did you compile the Perl binary yourself or are you using the one that came with the system? If you did it yourself, try again with Configure -de. Also, I seem to recall an issue with GCC and XCode that might affect you, but google knows all.

This could be bad physical memory too, although if this happens repeatedly in the same spot, that cause is unlikely.

Does this script use a lot of memory (hundreds or thousands of megabytes?).

But I think the culprit might by the back references in the regexes. Try code without assigning the back references:

$lines[$l] =~ /\w+\((\w+)\-\d+\,\s(\w+)\-\d+\)/;
if (defined $1 && $1 eq $verbform) {
   $goodmatch = 1;
}

Also, try this code on a different machine with Perl. This probably won't happen there.

Good luck and hope this helps some.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜