Re: RAND_bytes() causes 50% CPU load program crash when using CAPI engine

2012-07-25 Thread Jakob Bohm

On 7/25/2012 3:01 PM, Florian Rüchel wrote:

Hi,

I have a tool which calls RAND_bytes() for a length of 16 bytes while 
using the CAPI engine and having set it to be used for all purposes. 
If I run it in my Visual Studio Debugger in executes perfectly, but if 
run from within a command shell, it hangs on this statement (I 
localized it with printf statements).

Now I am wondering what might be causing this problem.

Here is my system:
Windows 7 x64 Enterprise
cl: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 
16.00.30319.01 for 80x86

link: Microsoft (R) Incremental Linker Version 10.00.30319.01
OpenSSL was compiled with this toolset and so is this program.


I cannot reproduce this problem, i.e. creating a small sample program 
works perfectly. And since I cannot even debug it, I can't limit or 
search for the problem.


Any ideas why this might be caused and how I can track it down?



Try putting printf() statements inside RAND_bytes() to narrow it
further (I assume you compile OpenSSL yourself).

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  http://www.wisemo.com
Transformervej 29, 2730 Herlev, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Re: RAND_bytes() causes 50% CPU load program crash when using CAPI engine

2012-07-25 Thread carlyoung
On Wed 25/07/12 2:16 PM , Jakob Bohm jb-open...@wisemo.com sent:
On 7/25/2012 3:01 PM, Florian Rüchel wrote:
 Hi,

 I have a tool which calls RAND_bytes() for a length of 16 bytes while 
 using the CAPI engine and having set it to be used for all purposes. 
 If I run it in my Visual Studio Debugger in executes perfectly, but if 
 run from within a command shell, it hangs on this statement (I 
 localized it with printf statements).
 Now I am wondering what might be causing this problem.

 I cannot reproduce this problem, i.e. creating a small sample program 
 works perfectly. And since I cannot even debug it, I can't limit or 
 search for the problem.

 Any ideas why this might be caused and how I can track it down?


Try putting printf() statements inside RAND_bytes() to narrow it
further (I assume you compile OpenSSL yourself).

Further to Jakob's response - I believe that one of the things RAND_bytes may 
do is traverse heaps to gather additional entropy. I would ensure that you have 
no heap corruption too - use gflags and/or other tools to validate your process 
too. That could possibly explain why the sample program will not reproduce the 
issue.

Carl


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Re: RAND_bytes() causes 50% CPU load program crash when using CAPI engine

2012-07-25 Thread Florian Rüchel

Hi,

thanks for your responses. It seems this may actually be a heap 
corruption after all, as the following function causes the crash:
`heap_first(hentry,hlist.th32ProcessID,hlist.th32HeapID)` on line 521 
with version 1.0.1


I will investigate this further tomorrow and hopefully come up with 
some explanation.


Regards,
Florian

On 25.07.2012 16:41, carlyo...@keycomm.co.uk wrote:

On Wed 25/07/12 2:16 PM , Jakob Bohm jb-open...@wisemo.com sent:
On 7/25/2012 3:01 PM, Florian Rüchel wrote:

Hi,

I have a tool which calls RAND_bytes() for a length of 16 bytes 
while
using the CAPI engine and having set it to be used for all 
purposes.
If I run it in my Visual Studio Debugger in executes perfectly, but 
if

run from within a command shell, it hangs on this statement (I
localized it with printf statements).
Now I am wondering what might be causing this problem.


I cannot reproduce this problem, i.e. creating a small sample 
program

works perfectly. And since I cannot even debug it, I can't limit or
search for the problem.

Any ideas why this might be caused and how I can track it down?



Try putting printf() statements inside RAND_bytes() to narrow it
further (I assume you compile OpenSSL yourself).


Further to Jakob's response - I believe that one of the things
RAND_bytes may do is traverse heaps to gather additional entropy. I
would ensure that you have no heap corruption too - use gflags and/or
other tools to validate your process too. That could possibly explain
why the sample program will not reproduce the issue.

Carl



__
OpenSSL Project 
http://www.openssl.org
User Support Mailing List
openssl-users@openssl.org
Automated List Manager   
majord...@openssl.org


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org