On 21. 12. 2010 15:35, Marsh Ray wrote:
On 12/21/2010 06:44 AM, Matej Kurpel wrote:
How can I check if I am doing something bad to the heap, please? Sadly,
I am not so skilled C++ programmer (well, rather a noobish one) and I
mostly don't know about the inside stuff you were talking about here...
It's OK, everybody has to debug this problem occasionally.
Also, the code for C_SignInit is nearly the same as for C_DecryptInit
which works fine. Plus, when I only return non-CKR_OK error code from
C_SignInit (and do nothing else in it), it still crashes.
1. Go over all your code again and make sure nothing is writing past
the end of the memory you get from new/malloc, or someone else gives
to you. Search in your code for 'memcopy' and friends, a bad parameter
to those functions can easily cause this. Search for C-style (casts)
of pointers and reinterpret_cast.
I did. I have avoided memcpy (or any mem-related functions) just in case
anyway.
2. Make sure you don't pass a pointer to some object which remembers
it and then delete/free the pointer while that object is still using
it. Try simply commenting out everywhere you manually free memory. It
will be a memory leak, but you might be able to figure out which
one(s) cause the crash that way.
I don't free memory manually. The module is just a set of short C
functions so the variables are freed up automatically anyway.
3. See if you can reproduce the problem on Linux. Run it with Valgrind
and/or Electric Fence These are similar to PageHeap, often times open
source apps will already have a build configuration for that on Linux.
Can't test it on Linux since I am using the MS-only functions (like
sprintf_s). And my implementation of sockets use Winsock. Well, that's
the "interoperability" of C++ I guess...
I don't have the time and nerves to fiddle around with it in Linux anyway.
4. Test it with Microsoft's PageHeap tool. There's lots of
documentation on it and probably some forums that can help you with
that. If that doesn't find it right away, try re-building with the
Release Microsoft C Runtime library as discussed.
I have tried the PageHeap tool as you suggested. I have managed to
enable PageHeap for thunderbird.exe but then I was unable to figure out
what the output from that tool is? Does it write a log file for me
somewhere? Or how do I check the output of PageHeap?
From what I have read on Microsoft's PageHeap web page, they suggest
trying Application Verifier as an GUI alternative to PageHeap. I tried
it as well but when thunderbird.exe was added as an applicatin to
verify, I couldn't start it (it said "The application was unable to
start correctly (0xc0000142). Click OK to close the application"). I
tried both the x86 and x64 versions of Application Verifier, with same
results. I guess I am out of options here.
I would like to solve this problem very much. If I can be of more help -
if you need more info (or output from some more debugging programs),
just ask.
You can do it.
- Marsh
If I only was able to load the source code of Thunderbird in Visual
Studio, that would be great. I could debug it line-by-line as usual. Why
does it have to be so hard? :(
M. Kurpel
--
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto