[GH-ISSUE #2372] JtR MinGW builds (seem to) have memory corruptions #1585

Closed
opened 2026-10-15 04:20:45 +07:00 by bsakaguchi · 27 comments
Owner

Originally created by @ghost on GitHub (Jan 2, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2372

  • It is possible to crack using a native windows [1] build of JtR.
  • But, it is not possible to test it.
  • It always fails with heap corruption or bad memory access [2].

Steps to reproduce

  • Build on Windows and run JtR using --test or --test-full options.
  • Real cracking works (at least, I wasn't able to trigger an error).

Workaround

  • Build JtR with memdbg enabled (succeed even a --test-full=0).

System configuration

Win> john --list=build-info
Version: 1.8.0-jumbo-1-5448-g17a7687
Build: mingw64 64-bit SSE2-ac
SIMD: SSE2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1
$JOHN is 
Format interface version: 14
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
gcc version: 5.3.0
Crypto library: OpenSSL
OpenSSL library version: 01000207f
OpenSSL 1.0.2g  1 Mar 2016
GMP library version: 6.1.0
File locking: NOT supported by this build - do not run concurrent sessions!
fseek(): fseeko64
ftell(): ftello64
fopen(): fopen64
memmem(): JtR internal

Other information

Seems NOT related to:


  • [1] I built JtR on someone's else HP Windows 7 notebook and I put JtR in a Windows CI service available online. I built and tested on i686 and x86_64.
  • [2] 0xC0000374: STATUS_HEAP_CORRUPTION or 0xC0000005: "memory access violation".

BTW: printf definitions, e.g. "LLu", have problems on 32bits.

Originally created by @ghost on GitHub (Jan 2, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2372 - It is possible to crack using a **native windows [1] build of JtR**. - But, it is not possible to test it. - It always fails with heap corruption or bad memory access [2]. ### Steps to reproduce - Build on Windows and run JtR using `--test` or `--test-full` options. - Real cracking works (at least, I wasn't able to trigger an error). ### Workaround - Build JtR with memdbg enabled (succeed even a `--test-full=0`). ### System configuration ``` Win> john --list=build-info Version: 1.8.0-jumbo-1-5448-g17a7687 Build: mingw64 64-bit SSE2-ac SIMD: SSE2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1 $JOHN is Format interface version: 14 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 gcc version: 5.3.0 Crypto library: OpenSSL OpenSSL library version: 01000207f OpenSSL 1.0.2g 1 Mar 2016 GMP library version: 6.1.0 File locking: NOT supported by this build - do not run concurrent sessions! fseek(): fseeko64 ftell(): ftello64 fopen(): fopen64 memmem(): JtR internal ``` ### Other information Seems **NOT** related to: - #2083 - #2190 **** * [1] I built JtR on someone's else HP Windows 7 notebook and I put JtR in a Windows CI service available online. I built and tested on i686 and x86_64. * [2] 0xC0000374: STATUS_HEAP_CORRUPTION or 0xC0000005: "memory access violation". **** BTW: printf definitions, e.g. "LLu", have problems on 32bits.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

What environment are you building with? The "LLu" works just fine, BUT it likely does not work for a very old compiler like VC6.

I build with 32 bit VC all the time, but I have to really hack the system to do it (build numerous files with mingw or cygwin and link in the .o files, like all the DES crap with inline asm code).

I would recommend just building with cygwin. You get a native Win32 or Win64 binary.

<!-- gh-comment-id:269966712 --> @jfoug commented on GitHub (Jan 2, 2017): What environment are you building with? The "LLu" works just fine, BUT it likely does not work for a very old compiler like VC6. I build with 32 bit VC all the time, but I have to really hack the system to do it (build numerous files with mingw or cygwin and link in the .o files, like all the DES crap with inline asm code). I would recommend just building with cygwin. You get a native Win32 or Win64 binary.
Author
Owner

@ghost commented on GitHub (Jan 2, 2017):

What environment are you building with?

MSYS2: mingw64 and mingw32.

It is possible to build using VC (using a sln file), but I can't hack the system.

<!-- gh-comment-id:269988834 --> @ghost commented on GitHub (Jan 2, 2017): > What environment are you building with? MSYS2: mingw64 and mingw32. It is possible to build using VC (using a sln file), but I can't hack the system.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

Try installing cygwin (if you can). Mingw is a pain in the ass. I have not worked on any porting issues for mingw for years. @kholia did get me to look into it as a cross compiler for Fedora (for the CI). But the end result exe is worthless. It runs under the CI (under wine), BUT crashes miserably when run on real windows. Cygwin has none of these issues, BUT it can not be run under linux (wine).

Oh, BTW, the "LLu" probably does not work under mingw. Mingw bases it's printf syntax on VC6 (one of the reasons I walked away from mingw a while back). VC6 does not know %llu only %I64u and mingw is the same in that regard.

The VC build is really hard. You have to pre-compile all of the .o files you want to use that have inline asm. You have to get the proper tools (mingw or cygwin), setup and 'configured' to have exactly the same config as will be used in the VC build. Then copy the generated .o files (tihings like x86.o). Then you have to get openssl with VC linkages, along with any other libs required (zlib might be the only other one).

I can send you the sln, but even with that, you would likely have to start over on your own env. NOTE, I use VC when debugging. You can not beat the debugger for speed of finding bugs. The debugger does have some limitations (no where near as powerful as some others), BUT it is super convenient and fast to use if you know how.

<!-- gh-comment-id:269992584 --> @jfoug commented on GitHub (Jan 2, 2017): Try installing cygwin (if you can). Mingw is a pain in the ass. I have not worked on any porting issues for mingw for years. @kholia did get me to look into it as a cross compiler for Fedora (for the CI). But the end result exe is worthless. It runs under the CI (under wine), BUT crashes miserably when run on real windows. Cygwin has none of these issues, BUT it can not be run under linux (wine). Oh, BTW, the "LLu" probably does not work under mingw. Mingw bases it's printf syntax on VC6 (one of the reasons I walked away from mingw a while back). VC6 does not know %llu only %I64u and mingw is the same in that regard. The VC build is really hard. You have to pre-compile all of the .o files you want to use that have inline asm. You have to get the proper tools (mingw or cygwin), setup and 'configured' to have exactly the same config as will be used in the VC build. Then copy the generated .o files (tihings like x86.o). Then you have to get openssl with VC linkages, along with any other libs required (zlib might be the only other one). I can send you the sln, but even with that, you would likely have to start over on your own env. NOTE, I use VC when debugging. You can not beat the debugger for speed of finding bugs. The debugger does have some limitations (no where near as powerful as some others), BUT it is super convenient and fast to use if you know how.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

Pretty much ANY win32/64 build is a one off, do it yourself, OTHER than a properly setup cygwin. The cygwin environment gives you a 99% Posix compliant environment, and it builds jtr very well (including GPU support with proper dev-libs installed). But other windows builds, you are sort of on your own. Mingw 'used' to work, but things have gone bad on that end. VC has never been officially supported, but I build under it, AND I thing @crioux also builds under it for his jtr_dll (not sure on that however). But the port to VC is definitely a one-off.

<!-- gh-comment-id:269992951 --> @jfoug commented on GitHub (Jan 2, 2017): Pretty much ANY win32/64 build is a one off, do it yourself, OTHER than a properly setup cygwin. The cygwin environment gives you a 99% Posix compliant environment, and it builds jtr very well (including GPU support with proper dev-libs installed). But other windows builds, you are sort of on your own. Mingw 'used' to work, but things have gone bad on that end. VC has never been officially supported, but I build under it, AND I thing @crioux also builds under it for his jtr_dll (not sure on that however). But the port to VC is definitely a one-off.
Author
Owner

@ghost commented on GitHub (Jan 2, 2017):

Since I'm just interested in do CI on Windows targeting a pure Windows, I'll keep the workaround on.

<!-- gh-comment-id:269999689 --> @ghost commented on GitHub (Jan 2, 2017): Since I'm just interested in do CI on Windows targeting a pure Windows, I'll keep the workaround on.
Author
Owner

@solardiz commented on GitHub (Jan 2, 2017):

Jim, I think we should seriously consider building with midipix, and fixing whatever issues with that remain.

<!-- gh-comment-id:270003489 --> @solardiz commented on GitHub (Jan 2, 2017): Jim, I think we should seriously consider building with midipix, and fixing whatever issues with that remain.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

@solardiz I looked at that a while back and it is NOT prime time at all.

Why is cygwin getting the cold shoulder? It is well supported, easy to install and maintain, works well for john, and is mostly OS (might be fully OS, I have never looked into it).

<!-- gh-comment-id:270006215 --> @jfoug commented on GitHub (Jan 2, 2017): @solardiz I looked at that a while back and it is NOT prime time at all. Why is cygwin getting the cold shoulder? It is well supported, easy to install and maintain, works well for john, and is mostly OS (might be fully OS, I have never looked into it).
Author
Owner

@solardiz commented on GitHub (Jan 2, 2017):

@jfoug I am not saying midipix is ready for its prime time, but it may be close to becoming good enough for use for JtR, especially with its maintainer interested in that (something we don't have for Cygwin, nor for any other similar project).

I like Cygwin, but I think builds with midipix may be closer to native Windows, with less library code. I think you experimented with MinGW and MSVC for similar reasons.

As you point out, Cygwin doesn't work in Wine. I think it also doesn't work in ReactOS, although this may be worth re-testing. (Arguably, these are also shortcomings of Wine and ReactOS, but the result in the same.) This prevents us from doing automated builds/CI for Windows on non-Windows and without needing a Windows license. We could try to avoid this issues with midipix, in cooperation with its maintainer.

We should also continue to support Cygwin.

<!-- gh-comment-id:270007448 --> @solardiz commented on GitHub (Jan 2, 2017): @jfoug I am not saying midipix is ready for its prime time, but it may be close to becoming good enough for use for JtR, especially with its maintainer interested in that (something we don't have for Cygwin, nor for any other similar project). I like Cygwin, but I think builds with midipix may be closer to native Windows, with less library code. I think you experimented with MinGW and MSVC for similar reasons. As you point out, Cygwin doesn't work in Wine. I think it also doesn't work in ReactOS, although this may be worth re-testing. (Arguably, these are also shortcomings of Wine and ReactOS, but the result in the same.) This prevents us from doing automated builds/CI for Windows on non-Windows and without needing a Windows license. We could try to avoid this issues with midipix, in cooperation with its maintainer. We should also continue to support Cygwin.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

Yes, that was exactly why I was using mingw. It did not carry the baggage of cygwin, BUT it simply started falling way short of things. A lot of new code has been added that are cool bells/whistles under *nix, but are not trivial to deal with. In VC usually you are pretty much out of luck on a lot of them (until they want to native support in the comipler). Mingw was VERY similar to VC, so a lot of that was also a road block. With cygwin, 'most' things worked just fine, and almost all the others had proper work arounds that used a few ugly #ifdefs, BUT they worked.

One big thing I was using mingw for, was for building libs (.a and .dll.a) to use with VC. However, I have since figured out how to do this with cygwin by linking in a couple of core .o files (clib and startup stuff), so I can now use cygwin to compile posix code where I need to do a 'configure' which was not capable of doing without a lot of work under VC (things like libgmp, libssl, libssh2, libcurl, etc). Yes, some of those 'do' have people that maintain a windows port. But I would rather start from non hacked 'current' code, simply do a ./configure && make or CMake (or whatever normal make proceedure is needed), and be able to link in something I built from sources.

I have been keeping my eye on midipix, and it 'may' be a good replacement for what mingw does (thin interface directly into win32 API). But I have not had time to do much more than 'know' it is there.

<!-- gh-comment-id:270008444 --> @jfoug commented on GitHub (Jan 2, 2017): Yes, that was exactly why I was using mingw. It did not carry the baggage of cygwin, BUT it simply started falling way short of things. A lot of new code has been added that are cool bells/whistles under *nix, but are not trivial to deal with. In VC usually you are pretty much out of luck on a lot of them (until they want to native support in the comipler). Mingw was VERY similar to VC, so a lot of that was also a road block. With cygwin, 'most' things worked just fine, and almost all the others had proper work arounds that used a few ugly #ifdefs, BUT they worked. One big thing I was using mingw for, was for building libs (.a and .dll.a) to use with VC. However, I have since figured out how to do this with cygwin by linking in a couple of core .o files (clib and startup stuff), so I can now use cygwin to compile posix code where I need to do a 'configure' which was not capable of doing without a lot of work under VC (things like libgmp, libssl, libssh2, libcurl, etc). Yes, some of those 'do' have people that maintain a windows port. But I would rather start from non hacked 'current' code, simply do a ./configure && make or CMake (or whatever normal make proceedure is needed), and be able to link in something I built from sources. I have been keeping my eye on midipix, and it 'may' be a good replacement for what mingw does (thin interface directly into win32 API). But I have not had time to do much more than 'know' it is there.
Author
Owner

@jfoug commented on GitHub (Jan 2, 2017):

Yes, the lack of build ability under Linux was why we resurrected the mingw building stuff. That DID perform a good win32 CI test. Works fine, and has certainly caught numerous bugs so far.

HOWEVER, while the resultant executable files run just fine on the CI (under wine on linux), they do not run well at all outside of wine. Yes, there are a few formats which do work, but a LARGE number of them, simply core. It is possibly DLL related (like libz, libgmp, libeay32), but I have looked into it. The CI 'work' was being done well, we just did not have a robot to build a 'release' executable.

<!-- gh-comment-id:270009535 --> @jfoug commented on GitHub (Jan 2, 2017): Yes, the lack of build ability under Linux was why we resurrected the mingw building stuff. That DID perform a good win32 CI test. Works fine, and has certainly caught numerous bugs so far. HOWEVER, while the resultant executable files run just fine on the CI (under wine on linux), they do not run well at all outside of wine. Yes, there are a few formats which do work, but a LARGE number of them, simply core. It is possibly DLL related (like libz, libgmp, libeay32), but I have looked into it. The CI 'work' was being done well, we just did not have a robot to build a 'release' executable.
Author
Owner

@ghost commented on GitHub (Jan 18, 2017):

There is a bug in code.

  • if I use __mingw_aligned_malloc(), I have to use its opposite, NOT free().

I volunteer to submit a patch, but we should think about it a little. For example:

  • how should we define ALL mem_allocs() and mem_frees() in a portable way.

RFC

<!-- gh-comment-id:273559611 --> @ghost commented on GitHub (Jan 18, 2017): There is a bug in code. * if I use __mingw_aligned_malloc(), I have to use its opposite, NOT free(). I volunteer to submit a patch, but we should think about it a little. For example: * how should we define ALL mem_allocs() and mem_frees() in a portable way. RFC
Author
Owner

@magnumripper commented on GitHub (Jan 18, 2017):

Can we just avoid using __mingw_aligned_malloc() at all? Are we not falling back ultimately to something very portable but perhaps slow or wasteful? I can't remember the details.

<!-- gh-comment-id:273606682 --> @magnumripper commented on GitHub (Jan 18, 2017): Can we just avoid using __mingw_aligned_malloc() at all? Are we not falling back ultimately to something very portable but perhaps slow or wasteful? I can't remember the details.
Author
Owner

@magnumripper commented on GitHub (Jan 18, 2017):

Aha...

(...)
#elif HAVE___MINGW_ALIGNED_MALLOC
	if (!(ptr = __mingw_aligned_malloc(size, align)))
		pexit("__mingw_aligned_malloc (%u bytes)", (unsigned)size);
#elif HAVE__ALIGNED_MALLOC
	if (!(ptr = _aligned_malloc(size, align)))
		pexit("_aligned_malloc ("Zu" bytes)", size);

#elif AC_BUILT
#error No suitable alligned alloc found, please report to john-dev mailing list (state your OS details).

I presume MinGW doesn't have _aligned_malloc so the alternative with current code would be the compiler error/bailout?

<!-- gh-comment-id:273607162 --> @magnumripper commented on GitHub (Jan 18, 2017): Aha... ```c (...) #elif HAVE___MINGW_ALIGNED_MALLOC if (!(ptr = __mingw_aligned_malloc(size, align))) pexit("__mingw_aligned_malloc (%u bytes)", (unsigned)size); #elif HAVE__ALIGNED_MALLOC if (!(ptr = _aligned_malloc(size, align))) pexit("_aligned_malloc ("Zu" bytes)", size); #elif AC_BUILT #error No suitable alligned alloc found, please report to john-dev mailing list (state your OS details). ``` I presume MinGW doesn't have _aligned_malloc so the alternative with current code would be the compiler error/bailout?
Author
Owner

@magnumripper commented on GitHub (Jan 18, 2017):

Just talking without thinking here, but how about this: For MinGW builds, ensure all allocs are using __mingw_aligned_malloc (perhaps defaulting to align == sizeof(long long) although we can probably just use 1) and then we can simply always use __mingw_aligned_free for all calls to MEM_FREE(). Could it be that simple?

It will be slightly wasteful for non-aligned allocs but it's not often used in hot code and who cares about that miserable platform anyway.

Also, this would (in my mind) be a tiny fix in memory.[ch] that should just solve it for good.

<!-- gh-comment-id:273608196 --> @magnumripper commented on GitHub (Jan 18, 2017): Just talking without thinking here, but how about this: For MinGW builds, ensure **all** allocs are using __mingw_aligned_malloc (perhaps defaulting to align == sizeof(long long) although we can probably just use 1) and then we can simply always use __mingw_aligned_free for **all** calls to MEM_FREE(). Could it be that simple? It will be slightly wasteful for non-aligned allocs but it's not often used in hot code and who cares about that miserable platform anyway. Also, this would (in my mind) be a tiny fix in memory.[ch] that should just solve it for good.
Author
Owner

@jfoug commented on GitHub (Jan 18, 2017):

so the alternative with current code would be the compiler error/bailout?

That is correct.

ensure all allocs are using __mingw_aligned_malloc

This is exactly what was done with VC, since it has it's own non-portable way to do aligned allocs. So in a VC build, ALL allocation is done aligned, and ALL frees are done with the aligned free. libc free CAN NOT be used on VC's aligned frees. The only way I was able to get it working was to do just like you mention here.

NOTE, this is more than simply MEM_FREE. You also have to define free at the proper location, to be the aligned_free (also have to deal with a wrapper for strdup, etc, IIRC). But it has been done on VC, so 'should' be able to be handled in the same manner for mingw. Actually mingw 'may' have the same function used for VC (since it uses the mscrt.dll), 'so' that VC specific code 'might' be able to simply be used for VC and mingw (untested).

<!-- gh-comment-id:273625933 --> @jfoug commented on GitHub (Jan 18, 2017): > so the alternative with current code would be the compiler error/bailout? That is correct. > ensure all allocs are using __mingw_aligned_malloc This is exactly what was done with VC, since it has it's own non-portable way to do aligned allocs. So in a VC build, ALL allocation is done aligned, and ALL frees are done with the aligned free. libc free CAN NOT be used on VC's aligned frees. The only way I was able to get it working was to do just like you mention here. NOTE, this is more than simply MEM_FREE. You also have to define free at the proper location, to be the aligned_free (also have to deal with a wrapper for strdup, etc, IIRC). But it has been done on VC, so 'should' be able to be handled in the same manner for mingw. Actually mingw 'may' have the same function used for VC (since it uses the mscrt.dll), 'so' that VC specific code 'might' be able to simply be used for VC and mingw (untested).
Author
Owner

@ghost commented on GitHub (Jan 18, 2017):

Just talking without thinking here, but how about this: For MinGW builds, ensure all allocs are using __mingw_aligned_malloc

Like VC. Indeed, a patch like this works.

diff --git a/src/memory.c b/src/memory.c
index aa41466..13ff401 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -25,7 +25,7 @@
 #include "johnswap.h"
 #include "memdbg.h"
 
-#if defined (_MSC_VER) && !defined (MEMDBG_ON)
+#if (defined (_MSC_VER) || HAVE___MINGW_ALIGNED_MALLOC) && !defined (MEMDBG_ON)
 char *strdup_MSVC(const char *str)
 {
 	char * s;
diff --git a/src/memory.h b/src/memory.h
index 73a7e77..1fde51d 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -156,6 +156,24 @@ char *strdup_MSVC(const char *str);
 }
 #endif
 
+#elif HAVE___MINGW_ALIGNED_MALLOC
+#if !defined (MEMDBG_ON)
+#define malloc(a) __mingw_aligned_malloc(a,16)
+#define realloc(a,b) __mingw_aligned_realloc(a,b,16)
+#define calloc(a,b) memset(__mingw_aligned_malloc(a*b,16),0,a*b)
+#define free(a) __mingw_aligned_free(a)
+#define strdup(a) strdup_MSVC(a)
+char *strdup_MSVC(const char *str);
+
+#define MEM_FREE(ptr) \
+{ \
+	if ((ptr)) { \
+		__mingw_aligned_free((ptr)); \
+		(ptr) = NULL; \
+	} \
+}
+#endif
+
 #else
 #define MEM_FREE(ptr) \
 { \
<!-- gh-comment-id:273629929 --> @ghost commented on GitHub (Jan 18, 2017): > Just talking without thinking here, but how about this: For MinGW builds, ensure all allocs are using __mingw_aligned_malloc Like VC. Indeed, a patch like this works. ``` diff --git a/src/memory.c b/src/memory.c index aa41466..13ff401 100644 --- a/src/memory.c +++ b/src/memory.c @@ -25,7 +25,7 @@ #include "johnswap.h" #include "memdbg.h" -#if defined (_MSC_VER) && !defined (MEMDBG_ON) +#if (defined (_MSC_VER) || HAVE___MINGW_ALIGNED_MALLOC) && !defined (MEMDBG_ON) char *strdup_MSVC(const char *str) { char * s; diff --git a/src/memory.h b/src/memory.h index 73a7e77..1fde51d 100644 --- a/src/memory.h +++ b/src/memory.h @@ -156,6 +156,24 @@ char *strdup_MSVC(const char *str); } #endif +#elif HAVE___MINGW_ALIGNED_MALLOC +#if !defined (MEMDBG_ON) +#define malloc(a) __mingw_aligned_malloc(a,16) +#define realloc(a,b) __mingw_aligned_realloc(a,b,16) +#define calloc(a,b) memset(__mingw_aligned_malloc(a*b,16),0,a*b) +#define free(a) __mingw_aligned_free(a) +#define strdup(a) strdup_MSVC(a) +char *strdup_MSVC(const char *str); + +#define MEM_FREE(ptr) \ +{ \ + if ((ptr)) { \ + __mingw_aligned_free((ptr)); \ + (ptr) = NULL; \ + } \ +} +#endif + #else #define MEM_FREE(ptr) \ { \ ```
Author
Owner

@jfoug commented on GitHub (Jan 18, 2017):

That likely is all there is to it. The one caveat function I had was that strdup. Since it handles this already, simply using the MinGW defines to also enter that code, and then getting the proper mingw_aligned alloc and free functions setup and re-defining alloc, free and realloc to use the aligned stuff, I 'think' it should work.

Do we want to 'force' this to 16? I did that for VC, and if all we deal with is data needing 16 byte alignment (SIMD SSE type stuff), then all is well. The VC build is not really a 'production' type build. I mostly use it for debugging and writing 'new' code (better edit/build/test environment for me). But that wrapping of all mallocs into aligned stuff does not seem to impact performance at all. Memory footprint is only a little bit worse. BUT I bet there would be formats where memory usage could be considerably worse. However, the alternative is to never allow SIMD logic in mingw, or anything that would require aligned allocations.

<!-- gh-comment-id:273632304 --> @jfoug commented on GitHub (Jan 18, 2017): That likely is all there is to it. The one caveat function I had was that strdup. Since it handles this already, simply using the MinGW defines to also enter that code, and then getting the proper mingw_aligned alloc and free functions setup and re-defining alloc, free and realloc to use the aligned stuff, I 'think' it should work. Do we want to 'force' this to 16? I did that for VC, and if all we deal with is data needing 16 byte alignment (SIMD SSE type stuff), then all is well. The VC build is not really a 'production' type build. I mostly use it for debugging and writing 'new' code (better edit/build/test environment for me). But that wrapping of all mallocs into aligned stuff does not seem to impact performance at all. Memory footprint is only a little bit worse. BUT I bet there would be formats where memory usage could be considerably worse. However, the alternative is to never allow SIMD logic in mingw, or anything that would require aligned allocations.
Author
Owner

@magnumripper commented on GitHub (Jan 18, 2017):

Do we want to 'force' this to 16?

Not sure what you mean. If the original code was an actual mem_alloc_align then we obviously use the align that was supplied. If the original call was just malloc, then we can default to sizeof(long long) or 1 or whatever else could be sensible.

<!-- gh-comment-id:273633248 --> @magnumripper commented on GitHub (Jan 18, 2017): > Do we want to 'force' this to 16? Not sure what you mean. If the original code was an actual mem_alloc_align then we obviously use the `align` that was supplied. If the original call was just malloc, then we can default to sizeof(long long) or 1 or whatever else could be sensible.
Author
Owner

@ghost commented on GitHub (Jan 19, 2017):

I'll PR.

<!-- gh-comment-id:273642521 --> @ghost commented on GitHub (Jan 19, 2017): I'll PR.
Author
Owner

@ghost commented on GitHub (Dec 20, 2017):

This bug is back. Even to be able to use the workaround, I had to remove problematic formats.

  • I had to remove bitlocker, blockchain, ethereum, geli, [1];

BTW: that said, I guess the GitHub Windows build could be also broken.

Dozens formats are passing, I'm just bored to remove one by one.

<!-- gh-comment-id:353139359 --> @ghost commented on GitHub (Dec 20, 2017): This bug is back. Even to be able to use the workaround, I had to remove problematic formats. * I had to remove bitlocker, blockchain, ethereum, geli, [1]; BTW: that said, I guess the GitHub Windows build could be also broken. Dozens formats are passing, I'm just bored to remove one by one.
Author
Owner

@frank-dittrich commented on GitHub (Dec 20, 2017):

You should be able to do

for f in `./john --list=format-details|cut -f 1`
do
  ./john --test --format=$f
done

and be able to find all failing formats this way, no?

<!-- gh-comment-id:353147087 --> @frank-dittrich commented on GitHub (Dec 20, 2017): You should be able to do ``` for f in `./john --list=format-details|cut -f 1` do ./john --test --format=$f done ``` and be able to find all failing formats this way, no?
Author
Owner

@ghost commented on GitHub (Dec 20, 2017):

It is windows: I have to convert to PS and do the equivalent || true since I'm inside CI.

<!-- gh-comment-id:353151560 --> @ghost commented on GitHub (Dec 20, 2017): It is windows: I have to convert to PS and do the equivalent `|| true` since I'm inside CI.
Author
Owner

@ghost commented on GitHub (Dec 21, 2017):

I bet the GitHub Windows build is broken. It has to be.

There is a bug in 551e468b70.


Not sure who is using it, but, since the build itself cannot be properly tested, it might be a bad idea to offer it as a official stuff.

<!-- gh-comment-id:353240636 --> @ghost commented on GitHub (Dec 21, 2017): I bet the GitHub Windows build is broken. It has to be. There is a bug in 551e468b70c4e40a9d6ee5437d3df92d62bdc03a. **** Not sure who is using it, but, since the build itself cannot be properly tested, it might be a bad idea to offer it as a official stuff.
Author
Owner

@magnumripper commented on GitHub (Dec 21, 2017):

We should at least clearly mark it as a "bleeding edge snapshot" build.

<!-- gh-comment-id:353292472 --> @magnumripper commented on GitHub (Dec 21, 2017): We should at least clearly mark it as a "bleeding edge snapshot" build.
Author
Owner

@kholia commented on GitHub (Dec 21, 2017):

I believe that I may have introduced this problem in commit 551e468 (as hinted by @claudioandre).

+// #define strdup(a) strdup_MSVC(a) // this is breaking MinGW cross-compiler builds of bitlocker2john.c

@claudioandre Does reverting this commit solves the memory corruption problem in MinGW builds?

<!-- gh-comment-id:353294111 --> @kholia commented on GitHub (Dec 21, 2017): I believe that I may have introduced this problem in commit 551e468 (as hinted by @claudioandre). ``` +// #define strdup(a) strdup_MSVC(a) // this is breaking MinGW cross-compiler builds of bitlocker2john.c ``` @claudioandre Does reverting this commit solves the memory corruption problem in MinGW builds?
Author
Owner

@ghost commented on GitHub (Dec 21, 2017):

Yes (as seen in Win 2012)

image

<!-- gh-comment-id:353341997 --> @ghost commented on GitHub (Dec 21, 2017): Yes (as seen in Win 2012) ![image](https://user-images.githubusercontent.com/1702923/34256344-f5646364-e63b-11e7-95bf-b8ed9df8cfe2.png)
Author
Owner

@kholia commented on GitHub (Dec 22, 2017):

The recent memory corruption issue was fixed in https://github.com/magnumripper/JohnTheRipper/pull/3043. Closing this bug now.

<!-- gh-comment-id:353599637 --> @kholia commented on GitHub (Dec 22, 2017): The recent memory corruption issue was fixed in https://github.com/magnumripper/JohnTheRipper/pull/3043. Closing this bug now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1585
No description provided.