-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory allocation not properly aligned on Windows platforms. #29
Comments
That's the problem I constantly run at on Windows! I have reported it multiple times, and I thought I am the only person who experiences it! Thank you, Mr. Viehland! |
"Decryption happens just fine, it’s cleanup that aborts." |
Credit to Christopher Mohr, who came up with the solution. |
If the issue is fixed, I will finally manage to finish my project! |
What version of Windows, and what version of Visual Studio? And do you have a minimal working example to demonstrate it? (I've never been able to duplicate it). |
Windows 7 64-bit Professional, Service Pack 1
My `minimal' example unfortunately used proprietary code. |
Same Windows version here, although the compiler is different. |
I've asked Chris, who still has cryptopp set up for debugging. Perhaps he'll be able to respond. |
Seems as though you are correct that this is not a cryptopp bug; however, I'm glad we've documented this as it is drawing attention from others who have experienced the problem. "In VS2008, malloc is required to return 16 byte aligned memory
which means any struct containing it needs to be 8 byte aligned [...]" |
Oh, I did not say that :) It may well be a Crypto++ bug; or it may be a platform bug that Crypto++ can help an application work around. About all I said was I'd like to see the bug in action so we can confirm it and determine a course of action. The course of action can be anything from user education to a bug fix. It almost sounds like you need a If you are using the MMX coprocessor for anything, then you definitely want the |
@JeremyViehland, @IlyaBizyaev - we added some documentation for the If you can reduce it to a minimum test case, then that would be immensely helpful. |
@jeremy - Can you test this under the latest check-in? I'm curious to know if you still experience the issue. |
@noloader, I have been working with Jeremy on this. I tested out the latest released version (5.6.3) with our previously failing code. I still get the failing assertion. Sorry, still no test case that doesn't rely on proprietary code. My previous tests showed that our custom memory allocator was probably to blame, as it gave wrongly aligned blocks of memory. |
@JeremyViehland, @ChrisPMohr - we found two issues in
Second, I believe I introduced the second issue when cutting over to We found the issues after adding a code coverage tool to ensure we had test cases set up. The tool identified a couple of functions that we thought were being tested but were not. Once we added the tests, we cleared the issues. I don't think they affect you, but I wanted to pass it on so it does not become a issue for you in the future. Obviously, the fixes are in Master, and they will be cleared at large in the next release of the library. |
@ChrisPMohr - Thanks Chris. I'm going to close this based on "My previous tests showed that our custom memory allocator was probably to blame, as it gave wrongly aligned blocks of memory...." Is that OK with you? |
Not sure if you read this message, but the problem still exists on MinGW. However, I have managed to compile using TDM-GCC-64, and there everything is OK. So, that IS a Crypto++ problem. |
Same problem here:
reallocate() is called in secblock.h:967 from
Here's the code:
In the debugger, newSize == 60. This happens when I call CryptoPP::RandomNumberGenerator::GenerateBlock() many times (typically more than 1000 or so). The stack trace goes like this:
This is the gist of my code:
I'm basically invoking operator() many times in a loop:
Microsoft Visual C++ Runtime Library reports: The Block at 0x... was allocated by aligned routines, use _aligned_free() Output:
|
If you can reduce the problem to a single source file I can run and verify, then it would be a big help. Please run a debug build of the library. We added asserts to help detect the condition closer to when it happens. A debug build is triggered with If I recall correctly, IlyaBizyaev's issues were due to mixing/matching versions of the Crypto++ library. Can you please remove all old versions of the Crypto++ library. Finally, please run the library's test suite and ensure all tests pass without error:
|
Assertion failed: m_allocated
cryptopp\secblock.h, line 197
Here's the workaround.
Here's the stack trace of the assertion
The text was updated successfully, but these errors were encountered: