Discussion:
[rt.cpan.org #120038] [PATCH] Fix build for VS2015 (VC++ 14)
(too old to reply)
Steve Hay via RT
2017-01-30 11:18:26 UTC
Permalink
Mon Jan 30 06:18:25 2017: Request 120038 was acted upon.
Transaction: Ticket created by SHAY
Queue: PAR-Packer
Subject: [PATCH] Fix build for VS2015 (VC++ 14)
Broken in: (no value)
Severity: (no value)
Owner: Nobody
Requestors: ***@cpan.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=120038 >


Using the patch called "perl-5.24.1-vc14.patch" attached to rt.perl.org #125714 I am able to build perl using the latest Visual Studio 2015 (VC++ 14.0), but PAR::Packer fails to build with that perl and compiler.

The attached patch fixes this. I found and fixed three problems:

1. Manifest files are not generated by default (and haven't been for a while now, actually) so they should not be embedded if not present. ExtUtils::MakeMaker and other similar tools already have similar code.

2. The new VC++ has a massively rewritten CRT and now defines some printf type functions inline, so the #define of snprint is no longer required.

3. I found that boot.exe was crashing on exit with the following call stack:

ntdll.dll!RtlpFreeHeap() Unknown
ntdll.dll!RtlFreeHeap() Unknown
ucrtbase.dll!___acrt_add_locale_ref() Unknown
ucrtbase.dll!___dcrt_uninitialize_environments_nolock() Unknown
ucrtbase.dll!___acrt_uninitialize_lowio() Unknown
ucrtbase.dll!___acrt_execute_uninitializers() Unknown
ucrtbase.dll!___acrt_add_locale_ref() Unknown
ucrtbase.dll!***@12() Unknown
ucrtbase.dll!***@12() Unknown
ntdll.dll!***@16() Unknown
ntdll.dll!LdrpCallInitRoutine() Unknown
ntdll.dll!LdrShutdownProcess() Unknown
ntdll.dll!RtlExitUserProcess() Unknown
kernel32.dll!***@4() Unknown
ucrtbase.dll!_swprintf() Unknown
ucrtbase.dll!_swprintf() Unknown
ucrtbase.dll!_exit() Unknown
boot.exe!main(int argc, char * * argv, char * * env) Line 234 C
That suggested a problem freeing memory, and code in env.c's par_setenv() function looked like an obvious candidate for causing corruption because of the way that it mallocs/reallocs chunks of the environ array, which is really managed by the CRT. I don't know why it worked in the past and breaks now, but documentation of _putenv() at https://msdn.microsoft.com/en-us/library/83zh4e6k.aspx does warn "Do not change an environment entry directly: instead, use _putenv or _wputenv to change it. In particular, direct freeing elements of the _environ[] global array might lead to invalid memory being addressed." Presumably the change is again to do with the CRT rewrite. Anyway, changing par_setenv() to simply call _putenv() on Windows fixes the crash.

Please consider this patch for your next release of PAR::Packer.

Many thanks for keeping this great tool alive!
Roderich Schupp via RT
2017-01-30 18:15:41 UTC
Permalink
Mon Jan 30 13:15:28 2017: Request 120038 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Packer
Subject: [PATCH] Fix build for VS2015 (VC++ 14)
Broken in: (no value)
Severity: (no value)
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=120038 >
Post by Steve Hay via RT
Using the patch called "perl-5.24.1-vc14.patch" attached to
rt.perl.org #125714 I am able to build perl using the latest Visual
Studio 2015 (VC++ 14.0), but PAR::Packer fails to build with that perl
and compiler.
Applied, thanks very much!

Cheers, Roderich

Loading...