Assertion failure and access violation error in gnutls

Nikos Mavrogiannopoulos nmav at gnutls.org
Tue Feb 1 18:55:15 CET 2011


On 02/01/2011 08:59 AM, snigdhamukherjee at bel.co.in wrote:
> Hello,
> 
> I am writing a proxy code for windows based clients. The browser connects
> to the HTTP proxy via localhost and port. The proxy initiates the tls
> session between the client proxy and backend server. The handshake happens
> between the client proxy and backend server and encrypted data flows. The
> browser only receives and sends non-encrypted data to and from client
> proxy.
> The client proxy uses libgnutls for tls functionality which internally
> uses libgcrypt.
> 1. Assertion failed in file ath.c line 193. Expression:
*lock==MUTEX_Unlocked

The problems you describe are due to memory corruption due to
lack of locks. I'd suggest the you try the implicit pthread locks
as in:
http://www.gnu.org/software/gnutls/manual/html_node/Multi_002dthreaded-applications.html

(the git version of gnutls uses that, and allows overriding it, if
required).

> int main()
> {
> 	if(!g_thread_supported())
> 		g_thread_init (NULL);
> 	gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_gthreads_cbs);

> 	gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
> 	gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
> 	gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
> 	gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
Why do you use this stuff?

> The library used for threading is glib. But this also has not resolved the
> problem. Am i doing something wrong during initialization?

I don't see anything obvious, but since you still have the problem
there is something there.

> 
> 2. The second problem I am facing is "access violation reading location"
> in gnutls_handshake(). Sometimes during handshake the debugger stops and
> tells unhandeled exception in clientproxy.exe; access violation reading
> location 0x..... I have no idea how to resolve this. So, please can
> someone help??

If you have a threading issue it is normal to expect memory corruption.
First solve the issue with threads and later check that. If you want
to debug this kind of errors, I'd suggest valgrind.

regards,
Nikos




More information about the Gnutls-help mailing list