Skip Menu |

This queue is for tickets about the true CPAN distribution.

Report information
The Basics
Id: 63148
Status: resolved
Priority: 0/
Queue: true

People
Owner: CHOCOLATE [...] cpan.org
Requestors: CHORNY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.12
Fixed in: 0.13



Subject: tests fail on Windows
See this cpantesters report (my report was lost somewhere): http://www.cpantesters.org/cpan/report/3156762c-6ccc-1014-9d99-1e16178f6054 -- Alexandr Ciornii, http://chorny.net
Here's the diagnosis: file separators. When Perl loads a module, it uses / so Foo::Bar becomes Foo/Bar.pm. But on Windows your @INC might contain \. CopFILE is returning the full path to the pm file by essentially going join "/", $INC, "Foo/Bar.pm" so you wind up with things like C:\foo\bar\lib/Foo/Bar.pm which isn't going to match anything sensible. Adding to the problem, the filename returned by Devel::StackTrace is native. On Windows that will be C:\foo\bar\lib\Foo\Bar.pm which gets shoved into %TRUE. So true_enabled() doesn't work. The filename has to be normalized both in ccfile() and true_ccfile(). My C coding sucks so I can't fix true_ccfile().
Schwern: many thanks for the detailed analysis. I've been bitten by that before (with PAR). I'm not sure it's the cause of those failures in this case, however. The paths shouldn't matter (i.e. they're not actually used for file access). It should only matter that the XS and the perl are using the same %INC keys. 0.13 cleans up the perl side of that equation, and passes the old tests OK (as well as some new tests) on Strawberry Perl. I'll leave the ticket open for now, but hopefully that should solve this issue. Obviously, please holler if I've overlooked something. Thanks again, chocolateboy.
From: mattn.jp [...] gmail.com
Hi, This is problem caused by backslash/slash of filename on windows. Here is a patch for fixing this problem. Please check and include. Thanks. - Yasuhiro Matsumoto On 2011-1月-27 木 03:12:40, CHOCOLATE wrote: Show quoted text
> Schwern: many thanks for the detailed analysis. I've been bitten by
that Show quoted text
> before (with PAR). > > I'm not sure it's the cause of those failures in this case, however.
The Show quoted text
> paths shouldn't matter (i.e. they're not actually used for file
access). Show quoted text
> It should only matter that the XS and the perl are using the same %INC
keys. Show quoted text
> > 0.13 cleans up the perl side of that equation, and passes the old
tests Show quoted text
> OK (as well as some new tests) on Strawberry Perl. I'll leave the
ticket Show quoted text
> open for now, but hopefully that should solve this issue. Obviously, > please holler if I've overlooked something. > > Thanks again, > chocolateboy.
Subject: true-0.12-fix-win32.diff
diff -ur true-0.12.orig/lib/true.pm true-0.12/lib/true.pm --- true-0.12.orig/lib/true.pm 2010-08-18 03:02:35.000000000 +0900 +++ true-0.12/lib/true.pm 2011-01-27 19:01:13.000890600 +0900 @@ -23,6 +23,7 @@ next unless ($sub =~ /::BEGIN$/); my $prev_frame = $trace->prev_frame; $ccfile = $prev_frame->filename; + $ccfile =~ s!\\!/!g if $^O eq 'MSWin32'; $ccline = $prev_frame->line; last; } diff -ur true-0.12.orig/true.xs true-0.12/true.xs --- true-0.12.orig/true.xs 2010-08-18 00:03:33.000000000 +0900 +++ true-0.12/true.xs 2011-01-27 19:05:06.328242900 +0900 @@ -25,6 +25,16 @@ STATIC void true_leave(pTHX); STATIC void true_unregister(pTHX_ const char *filename); +#ifdef _WIN32 +STATIC void win32_normalize_filename(const char * const filename) { + char* ptr = (char *) filename; // break force! + while(*ptr) { + if (*ptr == '\\') *ptr = '/'; + ptr++; + } +} +#endif + STATIC char * true_ccfile(pTHX) { return CopFILE(&PL_compiling); } @@ -46,6 +56,9 @@ STATIC void true_unregister(pTHX_ const char *filename) { /* warn("deleting %s\n", filename); */ +#ifdef _WIN32 + win32_normalize_filename(filename); +#endif (void)hv_delete(TRUE_HASH, filename, (I32)strlen(filename), G_DISCARD); if (HvKEYS(TRUE_HASH) == 0) { @@ -58,6 +71,9 @@ char * ccfile = true_ccfile(aTHX); PERL_UNUSED_VAR(user_data); +#ifdef _WIN32 + win32_normalize_filename(ccfile); +#endif if (true_enabled(aTHX_ ccfile)) { op_annotate(TRUE_ANNOTATIONS, o, ccfile, NULL); o->op_ppaddr = true_leaveeval; @@ -72,6 +88,9 @@ SV ** newsp; OPAnnotation * annotation = op_annotation_get(TRUE_ANNOTATIONS, PL_op); const char *filename = annotation->data; +#ifdef _WIN32 + win32_normalize_filename(filename); +#endif cx = &cxstack[cxstack_ix]; newsp = PL_stack_base + cx->blk_oldsp;
Show quoted text
> Please check and include.
Thanks for the patch. This should be fixed in true 0.13: http://search.cpan.org/~chocolate/true-0.13/