On Sun, 07 Aug 2011, Erland Sommarskog wrote:
> 
> I was able to resolve the problem. Although I ran into another, eh,
> interesting issue.
> 
> The problem was that in my Makefile.pl I had:
> 
>     'CCFLAGS'     => '/MT /W3', # Debug-flag: '/Zi',
>     'OPTIMIZE'     => '/O2',
> 
> That is, I entirely overrode whatever came with $Config. I got away with
> it for a long time, but finally time caught up with me. I changed this to:
> 
>    my $ccflags = $Config{'ccflags'};
>    my $optimize = $Config{'optimize'};
>    $ccflags =~ s/-MD\b/-MT/;
>    $optimize =~ s/-MD\b/-MT/;
>    $ccflags =~ s/-O1\b/-O2/;
>    $optimize =~ s/-O1\b/-O2/;
> 
> And everything works fine. Exactly what in $Config{'ccflags'} that was
> crucial I did not investigate. (But I don't use time_t.)

*Everyone* is using time_t if they are writing XS code. The interpreter
structure contains PL_basetime, which is of Time_t, which is #define'd
to be the same as time_t (look in intrpvar.h):

PERLVAR(Ibasetime, Time_t) /* $^T */

So if you use an incorrectly sized time_t, then all variables in the
Perl interpreter structure beyond PL_basetime will have the wrong offset
in your XS code and your extension will most likely crash.

Feel free to append -U_USE_32BIT_TIME_T again to the end of your CCFLAGS
to verify that this was indeed the problem. :)

Cheers,
-Jan


Reply via email to