davee123 has asked for the wisdom of the Perl Monks concerning the following question:
We've got a Perl script, it's reliably giving us a Segfault. I put debug in, and presto! Problem solved. Put it in the debugger? Works fine.
We've narrowed down the problem as follows. Our code:
... eval { $DT = DateTime->new( year => $year, time_zone => $tz ); }; return if $@; ...
Specifically, the above code executes normally several dozen times, and then segfaults when passed a $year of "2011", and a $tz of "Europe/London". BUT! Here's the catch, and here's where I'm getting out of my league:
JUST before that, it calls the same code with $year = "2010" and $tz = "Europe/London". THAT call fails and is successfully caught by the wrapped eval, which actually returns us an error message like this:
The 'name' parameter (undef) to DateTime::TimeZone::new was an 'undef' +, which is not one of the allowed types: scalar at /idcom/weblive/extperl/lib/perl5/site_perl/5.8.5/DateTime/TimeZone +.pm line 34 DateTime::TimeZone::new('undef', 'name', 'undef') called at /idcom/weblive/extperl/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread +-multi/DateTime.pm line 192 DateTime::new('undef', 'year', 2010, 'time_zone', 'Europe/Lond +on') called at TZInfo.pm line 33 TZInfo::get_dst_changes(2010, 'Europe/London') called at ./nz. +pl line 1039
The NEXT call (for 2011, same time zone), causes the segfault, and isn't caught by the wrapped eval.
So. One thing I noticed is that it reports that I called both DateTime::new and DateTime::TimeZone::new with a leading "undef" parameter! Shouldn't that be the package name?
Beyond that, I'm at a loss. I can't replicate it in a smaller, standalone test, and I have no idea why it should actually segfault. And looking at DateTime::new, it looks like it's possible that the Params::Validate module is what's processing the arguments and turning the name field into an undef-- but it seems wholly unlikely to me that there would be a bug in either DateTime, DateTime::TimeZone, or Params::Validate.
Any ideas?
DaveE
UPDATE
Well, not much to say apart from the fact that I've quasi-confirmed that Params::Validate isn't doing what it's supposed to do (probably thanks to some error state that we've created, but I have no idea how). Within DateTime.pm:... sub new { my $class = shift; my %p = validate( @_, $NewValidate ); ...
I added in debug (that still contained the failure) to print out @_, %p, and $NewValidate both before and after the call to Params::Validate. Result?
@_ set to: $VAR1 = [ 'year', 2010, 'time_zone', 'Europe/London' ]; %p set to: $VAR1 = {};
So, it properly shifted off the $class (it was being set correctly it seems), but when attempting to pass off to Params::Validate::validate, the resultant hash comes back empty! Trying to hack into Params::Validate now, but I have a feeling I'm barking up the wrong tree-- maybe something's screwed up the stack and comes unstuck at the return from Params::Validate or something, but again, I have doubts that the library itself has a problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tracking down a segfault
by zgpmax (Initiate) on Nov 19, 2020 at 17:55 UTC | |
|
Re: Tracking down a segfault
by runrig (Abbot) on Oct 24, 2011 at 19:17 UTC | |
|
Re: Tracking down a segfault
by bluescreen (Friar) on Oct 24, 2011 at 21:39 UTC | |
|
Re: Tracking down a segfault
by Anonymous Monk on Oct 25, 2011 at 12:44 UTC | |
by davee123 (Novice) on Oct 25, 2011 at 19:39 UTC | |
by Anonymous Monk on Oct 26, 2011 at 03:19 UTC |