SHA256 release build failing

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SHA256 release build failing

Farukh Sharipov
Hi 


I have code below for the SHA256 implementation it compiles and works fine in Debug but when switched to Release configuration it fails with following message: 

Exception thrown at 0x4296339C (cryptopp.dll) in CryptoppCPP.exe: 0xC0000005: Access violation reading location 0x6F57206F.
If there is a handler for this exception, the program may be safely continued.

Crypto++ v5.3.0 FIPS
VS2015 Visual C++ 2015
Below is C++ Command Line: 

 
/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"Release\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\CryptoppCPP.pch"

Linker Command Line: 

/OUT:"C:\Users\821973\Documents\Visual Studio 2015\Projects\CryptoppCPP\Release\CryptoppCPP.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"C:\Users\821973\Documents\Visual Studio 2015\Projects\CryptoppCPP\Release\CryptoppCPP.pdb" /DYNAMICBASE "C:\Users\821973\Documents\Visual Studio 2015\Projects\CryptoppCPP\libs\x86\cryptopp.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"C:\Users\821973\Documents\Visual Studio 2015\Projects\CryptoppCPP\Release\CryptoppCPP.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\CryptoppCPP.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

CPP

#include "main.h"
using namespace std;

USING_NAMESPACE
(CryptoPP)

#ifdef CRYPTOPP_IMPORTS

static PNew s_pNew = NULL;
static PDelete s_pDelete = NULL;


extern "C" __declspec(dllexport) void __cdecl SetNewAndDeleteFromCryptoPP(PNew pNew, PDelete pDelete, PSetNewHandler pSetNewHandler)
{
 s_pNew
= pNew;
 s_pDelete
= pDelete;
}


void * __cdecl operator new (size_t size)
{
 
return s_pNew(size);
}


void __cdecl operator delete (void * p)
{
 s_pDelete
(p);
}


#endif


int main()
{
 std
::cout << "Crypto++ Example" << endl;


 SHA256 hash
;
 
string message = "abcdefghijklmnopqrstuvwxyz";
 
string digest;


 
StringSource s(message, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));


 cout
<< digest << endl;
 


 system
("pause");


 
return 0;
}

H

#pragma once
#ifndef __SPDCRYPTO_H
#define __SPDCRYPTY_H
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <iostream>


#include "Include\dll.h"
#  pragma comment ( lib, "cryptopp" )
#endif


Does anyone came across this issue before? How can I track what could be causing this issue?

Thank you. 

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SHA256 release build failing

Jeffrey Walton-3


Does anyone came across this issue before? How can I track what could be causing this issue?

https://msdn.microsoft.com/en-us/library/y740d9d3.aspx and https://www.google.com/search?q=how+to+use+visual+studio+debugger.

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SHA256 release build failing

Farukh Sharipov
Thank you Jeffrey 

I do know how to use debugger and google :). 

Since issue is coming up in Release and not Debug I can't step inside the Crypto++ it just breaks on this line: 

StringSource s(message, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));

Best Regards
Farukh Sharipov


On Thursday, May 11, 2017 at 4:53:03 PM UTC-7, Jeffrey Walton wrote:


Does anyone came across this issue before? How can I track what could be causing this issue?

<a href="https://msdn.microsoft.com/en-us/library/y740d9d3.aspx" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fy740d9d3.aspx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGHQbQUenuXEr4sv3E5rfOPTvw6g&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fy740d9d3.aspx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGHQbQUenuXEr4sv3E5rfOPTvw6g&#39;;return true;">https://msdn.microsoft.com/en-us/library/y740d9d3.aspx and <a href="https://www.google.com/search?q=how+to+use+visual+studio+debugger" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/search?q\x3dhow+to+use+visual+studio+debugger&#39;;return true;" onclick="this.href=&#39;https://www.google.com/search?q\x3dhow+to+use+visual+studio+debugger&#39;;return true;">https://www.google.com/search?q=how+to+use+visual+studio+debugger.

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SHA256 release build failing

Farukh Sharipov
It breaks inside secblock.h line: 288


 void Assign(const T *t, size_type len)
 
{
 
New(len);
 memcpy_s
(m_ptr, m_size*sizeof(T), t, len*sizeof(T)); //<--BREAKS HERE
 
}



On Friday, May 12, 2017 at 9:43:08 AM UTC-7, Farukh Sharipov wrote:
Thank you Jeffrey 

I do know how to use debugger and google :). 

Since issue is coming up in Release and not Debug I can't step inside the Crypto++ it just breaks on this line: 

StringSource s(message, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));

Best Regards
Farukh Sharipov


On Thursday, May 11, 2017 at 4:53:03 PM UTC-7, Jeffrey Walton wrote:


Does anyone came across this issue before? How can I track what could be causing this issue?

<a href="https://msdn.microsoft.com/en-us/library/y740d9d3.aspx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fy740d9d3.aspx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGHQbQUenuXEr4sv3E5rfOPTvw6g&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fy740d9d3.aspx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGHQbQUenuXEr4sv3E5rfOPTvw6g&#39;;return true;">https://msdn.microsoft.com/en-us/library/y740d9d3.aspx and <a href="https://www.google.com/search?q=how+to+use+visual+studio+debugger" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/search?q\x3dhow+to+use+visual+studio+debugger&#39;;return true;" onclick="this.href=&#39;https://www.google.com/search?q\x3dhow+to+use+visual+studio+debugger&#39;;return true;">https://www.google.com/search?q=how+to+use+visual+studio+debugger.

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SHA256 release build failing

Jeffrey Walton-3
In reply to this post by Farukh Sharipov


On Friday, May 12, 2017 at 12:43:08 PM UTC-4, Farukh Sharipov wrote:
Thank you Jeffrey 

I do know how to use debugger and google :). 

Since issue is coming up in Release and not Debug I can't step inside the Crypto++ it just breaks on this line: 

StringSource s(message, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));

Just guessing...

On Windows and in the context of DLLs, you are ___not___ supposed to pass std::string (or other STL containers) through a DLL interface. You must use pointers and sizes. Here's one of Microsoft's old KB's about it: https://support.microsoft.com/en-us/help/813810 .

If you don't mind me asking, what is the aversion to providing the relevant source code and a stack trace? How do folks expect useful answers when the problem statement is "my DLL crashes" with no context and the question is "why".

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...