2
votes

I have integrated botan library for TLS security. I get below error:

First-chance exception at 0x6DBFD1CE (vcruntime140.dll) in jsonrpctest.exe: 0xC0000005: Access violation reading location 0x00962000. If there is a handler for this exception, the program may be safely continued

Below is the code I am calling

int main(int argc, char *argv[])
{
// prepare all the parameters
Callbacks callbacks;
Botan::AutoSeeded_RNG rng;
Botan::TLS::Session_Manager_In_Memory session_mgr(rng);
Client_Credentials creds;
Botan::TLS::Strict_Policy policy;

// open the tls connection : Error comes here
Botan::TLS::Client client(callbacks,
    session_mgr,
    creds,
    policy,
    rng,
    Botan::TLS::Server_Information("10.193.252.14", 43733),
    Botan::TLS::Protocol_Version::TLS_V12);

while (!client.is_closed())
{
    //cout << client.is_active;
    // read data received from the tls server, e.g., using BSD sockets or 
 boost asio
    // ...

    // send data to the tls server using client.send_data()
} }
1
Have you tried running under a debugger to at least determine the specific line that is causing the error?Sean Burton
@pankaj did you ever solve your issue? I am trying to build and test botan and every example program I try to run I get an exception for "Access violation reading location".BradStell

1 Answers

1
votes

The exact reason of this error is unknown. I think it's some build flag is visual studio maybe. I was getting similar error in the release build i made but it works fine in the debug build. Then i built it as a library (DLL) instead of an application (.exe) and i didn't see any issues. I think the best way to use Botan is to make an amalgamation build (i.e. not use the Botan DLL library but import Botan code into your application and then use it). Here is the build command that worked for me (run it from the Botan source folder):

configure.py --cpu=i386 --amalgamation --single-amalgamation-file --minimized-build --enable-modules=tls,x509,seed,rdseed,rdrand,rdrand_rng,auto_rng --disable-shared

You need to have Python installed and in path before running the above command. The above command will generate the following files in the Botan source code directory (i.e. same path where you run the above command):

botan_all.h, botan_all_internal.h and botan_all.cpp

You need to include these files as part of your application code, use it and build it.

More info on Botan amalgamation build: https://botan.randombit.net/manual/building.html#amalgamation