[GH-ISSUE #1200] memdbg does not honor alignment requests beyond sizeof(integer SIMD vector). #750

Closed
opened 2026-10-14 03:22:17 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @magnumripper on GitHub (Apr 12, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1200

Originally assigned to: @jfoug on GitHub.

When memdbg is used, if you ask for an alignment larger than 16 using mem_alloc_align(), you are actually 100% guaranteed to only get an aligment of 16. This in turns guarantees a segfault with eg. AVX2 or wider SIMD.

Originally created by @magnumripper on GitHub (Apr 12, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1200 Originally assigned to: @jfoug on GitHub. When memdbg is used, if you ask for an alignment larger than 16 using `mem_alloc_align()`, you are actually 100% guaranteed to only get an aligment of 16. This in turns guarantees a segfault with eg. AVX2 or wider SIMD.
bsakaguchi 2026-10-14 03:22:17 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Apr 26, 2015):

I think I have an idea how this should be solved. We need to add a union with vtype (which is typedef'ed in pseudo-intrinsics.h) to MEMDBG_HDR. Or simply pad with sizeof(vtype) - 16 bytes.

<!-- gh-comment-id:96448668 --> @magnumripper commented on GitHub (Apr 26, 2015): I think I have an idea how this should be solved. We need to add a union with vtype (which is typedef'ed in pseudo-intrinsics.h) to MEMDBG_HDR. Or simply pad with `sizeof(vtype) - 16` bytes.
Author
Owner

@magnumripper commented on GitHub (Apr 27, 2015):

8506e3c (and 717964fb51, e4a995ae) only made it slightly better, and usable with AVX2 and AVX512. Now, memdbg can't give you better alignment than sizeof(integer SIMD vector). If you ask for more (eg. MEM_ALIGN_CACHE) you will still only get MEM_ALIGN_SIMD. In most cases, this is sufficient but it's technically a bug in memdbg.

<!-- gh-comment-id:96450495 --> @magnumripper commented on GitHub (Apr 27, 2015): 8506e3c (and 717964fb51, e4a995ae) only made it slightly better, and usable with AVX2 and AVX512. Now, memdbg can't give you better alignment than sizeof(integer SIMD vector). If you ask for more (eg. MEM_ALIGN_CACHE) you will still only get MEM_ALIGN_SIMD. In most cases, this is sufficient but it's technically a bug in memdbg.
Author
Owner

@jfoug commented on GitHub (May 27, 2015):

This should be fixed (I think) in 20ce8fe

There is a #define in john.c (at the very start of main) that should test memdbg. It simple tests all alignments from 1 to 256. It checks that the alignment is correct

<!-- gh-comment-id:106076515 --> @jfoug commented on GitHub (May 27, 2015): This should be fixed (I think) in 20ce8fe There is a #define in john.c (at the very start of main) that should test memdbg. It simple tests all alignments from 1 to 256. It checks that the alignment is correct
Author
Owner

@jfoug commented on GitHub (May 28, 2015):

Can someone please test this with some data that requires > 16 byte alignment? I have tested with the test code in john.c, so I am pretty sure it is working properly. However, I am not going to close this one without hearing that 'real' code is working properly.

<!-- gh-comment-id:106405104 --> @jfoug commented on GitHub (May 28, 2015): Can someone please test this with some data that requires > 16 byte alignment? I have tested with the test code in john.c, so I am pretty sure it is working properly. However, I am not going to close this one without hearing that 'real' code is working properly.
Author
Owner

@magnumripper commented on GitHub (May 28, 2015):

An AVX2 build (with MEM_ALIGN_SIMD as 32) on well works like a champ. I also verified that MEM_ALIGN_CACHE and MEM_ALIGN_PAGE does what they should 👍

<!-- gh-comment-id:106585468 --> @magnumripper commented on GitHub (May 28, 2015): An AVX2 build (with MEM_ALIGN_SIMD as 32) on well works like a champ. I also verified that MEM_ALIGN_CACHE and MEM_ALIGN_PAGE does what they should :+1:
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#750
No description provided.