> I'm not sure I understand. Naturally, the OpenSSL-specific debugging
> hooks are made for OpenSSL primarely. If you want to get the benifits
> from within your application, you need to use the functions
> OPENSSL_malloc(), OPENSSL_realloc() and OPENSSL_free() for memory
> handling instead of malloc(), realloc() and free(). The rule of thumb
> is: if you want to get OpenSSL-specific feature, you need to use the
> corresponding OpenSSL functions/macros.
I'm using OpenSSL also in C++ application therefore I can not use OPENSSL_malloc for all objects, in some I must use the new/delete operator (otherwise no constructor/destructor will be invoked).
Still it does not metter, as you might see in the text that follows.
> Then I'm not really sure what
> the "without file name and number" means. They're certainly provide
> to the hooks/callbacks.
VC compiler writes all detected memory leaks to the debug output window as follows:
//////////////////////////////////////////////////////////////////////////////////////////////////
Detected memory leaks!
Dumping objects ->
E:\CRYPTO\bn\bn_lib.c(328) : {5667} normal block at 0x00A54200, 12 bytes long.
Data: < > 01 00 01 00 00 00 00 00 CD CD CD CD
//////////////////////////////////////////////////////////////////////////////////////////////////
Leaks of Memory that was allocated in OPENSSL_malloc are displayed as well, only that the file name and line number are missing.
(In the above sample it appears due to the hack I added to mem.c)
File name and lines are provide in the hooks/callbacks but if we want them in this output they should be passed to the allocating function.
>
> drorotmi> 2.) The windows programmer can not compile a debug version
> drorotmi> that will give this quite important information per default
> drorotmi> and in a way that he use to detect the leaks (that could be
> drorotmi> very usefull also in bug reports).
>
> Uhmm, I assume it's "a debug version" of OpenSSL.
Yes, the whole discussion refers actually only to the debug version and VC compiler.
> In what way can't
> you do that?
>
At the moment, in case of a memory leak, the leaks will be shown in the debug output window but without a reference to the file name and line number.
The debug output window is the first place a window programmer will search for memory leaks. It would be a great advatage if one could compile OpenSSL in a way that the compleet memory leak report will be displayed (e.g by a precompiler switch).
Since I use C++ and have a classes with which I could do the *book keeping* quit easy: I called CRYPTO_set_mem_debug_functions() to initiate the callbacks and could access the file name and line number.
Now if I want to use OpenSSL for the tracing, let's see if I understood it right:
To access the file name and line number one have to activate the memory tracing of OpenSSL, then at program exit CRYPTO_mem_leaks() should be invoked to write the report, correct????
For both methods you will need some expirience with OpenSSL and the memory leaks are reported twice: once by VC and once by the callback mechanism.
> drorotmi> Another alternative for this issue is to provide an
> drorotmi> interface for malloc_func & co. that matches the CRL
> drorotmi> library, so the programmer could assign those methods, this
> drorotmi> however, will require more work.
>
> Uhmm, exactly what kind of interface are you after? OpenSSL has hooks
> all over the place basically, and just provides internal defaults.
>
> Please assume that I know nothing about the CRT library, and am not
> likely to know anything about it in the near future, but that I can
> understand precise examples and code :-).
>
The functions interface (defined in crtdbg.h) is as follow:
void *_malloc_dbg( size_t size, int blockType, const char *filename, int linenumber );
void *_realloc_dbg( void *userData, size_t newSize, int blockType, const char *filename, int linenumber );
void _free_dbg( void *userData, int blockType );
If the memory is allocated using those method, the report that appears on the debug output window includes the link to the file name and line number.
As you might see, the allocating functions needs more arguments then the memory alocating functions of OpenSSL. This is way we can not assign those functions to them.
> drorotmi> Well it is a sort of *nice to have item*, as a window
> drorotmi> programmer, I will appreciate it very much if this will be
> drorotmi> available.
>
> Depends on what it is you want exactly.
>
The leaks of memory that was allocated in OpenSSL is displayed in the debug output window on program exit but without a link to the file name and line number.
The goal is that they will appear in the memory leak report as well.
Many thanks
Dror
______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
