I have a strange issue with a console app.
I have compiled the PolarSSL cryptography library and made a small C DLL which wraps up a couple of functions to allow me to create ripemd160 hashes and create an Elliptic Curve public key from a 256 bit Elliptic Curve private key. I’m doing some programs that work with Bitcoin and this is the basic functionality required to create and work with Bitcoin addresses.
I compiled it with MinGW on Windows and gcc on Linux / Mac - everything worked as expected apart from when I use it as a windows console app.
When I call a specific function from the dll/so/dylib inside the Xojo consoleapp it all works but when the program completes and exits a crash is reported on Windows. It only happens when the program completes, there are no errors when it’s running.
Note - This does not happen when I successfully run the exact same program within the IDE on Windows by clicking the big green ‘Play’ button, it only happens when I run it from the command line as a built application. This strikes me as being very odd behaviour.
In order to rule out a problem with the DLL I wrote a small C program to call the DLL and that also had no problems on Windows.
I isolated the specific part of the Polarssl library which causes this to happen.
It happens when I call the ‘ecdsa_init’ function ( https://polarssl.org/api/ecdsa_8h.html#a70bf12fe3c9062d5ee306378d94f8d67 ) within my compiled DLL. This function prepares the data structure which holds details about the elliptic curve being used. It’s quite complex in that it uses various data types including a custom bignum library which comes with the PolarSSL library.
When the same console program runs in the IDE it does not crash on termination, when it runs from the windows command line this is what happens :
I have a feeling it’s something to do with cleaning up memory before the program exits but that’s just a hunch.
Any ideas ?
I can post source code and samples if required. I have only tested this in console apps but I’ve tested it on all three platforms.
I am almost certain that this is nothing to do with PolarSSL - it’s a widely used professional commercial library which we’re allowed to use for open source projects.
I find it a little bizarre that the program completes without any issue when executed inside the IDE on Windows but not when it’s executed from the command prompt - what’s the difference between the two ?