Fri Jun 08 05:04:20 2018: Request 125503 was acted upon. Transaction: Correspondence added by SHAY Queue: PAR-Packer Subject: [PATCH] Fix build with 64-bit perl-5.28.0 Broken in: 1.043 Severity: (no value) Owner: Nobody Requestors: s...@cpan.org Status: new Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125503 >
I found another problem: Executables compiled with pp's -C argument crashed on exit due to another 64-bit bug, in par_rmtmpdir(). The _findfirst() function returns an intptr_t (a 32-bit integer in x86 builds, but 64-bit in x64 builds -- to hold the larger pointers) but it was being assigned to a long (a 32-bit integer in both x86 and x64 builds), so it got truncated. The attached pp-x64-v2.patch is a new version of the previous patch, which now includes this fix as well. I've also spotted one more use of struct stat which I think needs changing to par_stat_t, which is also done in this updated patch. I haven't tested this change myself since it affects only the non-WIN32 version of par_rmtmpdir(), so please be sure to test with the -C argument on a x64 build on some non-WIN32 platform.
diff -ruN --binary PAR-Packer-1.043.orig/myldr/mktmpdir.c PAR-Packer-1.043/myldr/mktmpdir.c --- PAR-Packer-1.043.orig/myldr/mktmpdir.c 2017-02-11 17:19:06.000000000 +0000 +++ PAR-Packer-1.043/myldr/mktmpdir.c 2018-06-08 09:54:02.853109100 +0100 @@ -21,7 +21,7 @@ static int isWritableDir(const char* val) { #ifndef PL_statbuf - struct stat PL_statbuf; + par_stat_t PL_statbuf; #endif return par_lstat(val, &PL_statbuf) == 0 && @@ -38,7 +38,7 @@ static int isSafeDir(const char* val) { #ifndef PL_statbuf - struct stat PL_statbuf; + par_stat_t PL_statbuf; #endif return par_lstat(val, &PL_statbuf) == 0 && @@ -301,7 +301,7 @@ int subsub_len; char *subsubdir; char *slashdot; - long hFile; + intptr_t hFile; int tries = 0; HMODULE dll; @@ -347,7 +347,7 @@ Direntry_t *dp; char *subsubdir = NULL; int subsub_len; - struct stat stbuf; + par_stat_t stbuf; /* remove temporary PAR directory */ if (!stmpdir || !*stmpdir) return; diff -ruN --binary PAR-Packer-1.043.orig/myldr/mktmpdir.h PAR-Packer-1.043/myldr/mktmpdir.h --- PAR-Packer-1.043.orig/myldr/mktmpdir.h 2017-02-04 23:29:19.000000000 +0000 +++ PAR-Packer-1.043/myldr/mktmpdir.h 2018-06-08 09:53:19.082324400 +0100 @@ -67,6 +67,12 @@ #define par_lstat stat #endif +#ifdef Stat_t +#define par_stat_t Stat_t +#else +#define par_stat_t struct stat +#endif + #if defined(WIN32) || defined(OS2) static const char *dir_sep = "\\"; static const char *path_sep = ";"; diff -ruN --binary PAR-Packer-1.043.orig/myldr/utils.c PAR-Packer-1.043/myldr/utils.c --- PAR-Packer-1.043.orig/myldr/utils.c 2017-03-12 17:26:54.000000000 +0000 +++ PAR-Packer-1.043/myldr/utils.c 2018-06-08 09:53:19.149620900 +0100 @@ -95,7 +95,7 @@ * to a struct stat. Try to distinguish these cases by checking * whether PL_statbuf is defined. */ #ifndef PL_statbuf -struct stat PL_statbuf; +par_stat_t PL_statbuf; #endif #ifdef WIN32