Crashed libpq.dll in a multithreaded environment in case of SSLconnection + callstack - Mailing list pgsql-bugs

From Ádám Maracska
Subject Crashed libpq.dll in a multithreaded environment in case of SSLconnection + callstack
Date
Msg-id CAJtpbKQZxkcqEWOAYVc54CyjjE6YDxBuMSjHRO+w6XTsGiys8g@mail.gmail.com
Whole thread Raw
Responses Re: Crashed libpq.dll in a multithreaded environment in case of SSLconnection + callstack  (csusza <csusza@gmail.com>)
List pgsql-bugs
Hi,

I am working in a multithreaded environment with at least 5 threads on a windows 10 x64 OS. 
Postgresql server: 9.6.9 also the used libpq.dll in my application is 9.6.9. 
SSL Version: 1.0.2o (The issue also occures with 1.0.2n) 

CallStack:
libeay32.dll!ssleay_rand_bytes(unsigned char * buf=0x000002382a57a428, int num=6, int pseudo=0, int lock=1) Line 506 C
ssleay32.dll!tls1_enc(ssl_st * s=0x000002382a56ed20, int send=1) Line 785 C
ssleay32.dll!do_ssl3_write(ssl_st * s=0x000002382a56ed20, int type=23, const unsigned char * buf=0x000002382a3eb0e0, unsigned int len=12, int create_empty_fragment=0) Line 1046 C
ssleay32.dll!ssl3_write_bytes(ssl_st * s=0x000002382a56ed20, int type=23, const void * buf_=0x000002382a3eb0e0, int len) Line 834 C
ssleay32.dll!ssl3_write(ssl_st * s=0x000002382a56ed20, const void * buf=0x000002382a3eb0e0, int len=12) Line 4442 C
libpq.dll!pgtls_write(pg_conn * conn=0x0000023827d8c240, const void * ptr=0x000002382a3eb0e0, unsigned __int64 len=12) Line 307 C
libpq.dll!pqsecure_write(pg_conn * conn=0x0000023827d8c240, const void * ptr=0x000002382a3eb0e0, unsigned __int64 len=12) Line 289 C
libpq.dll!pqSendSome(pg_conn * conn=0x0000023827d8c240, int len=12) Line 863 C
libpq.dll!pqFlush(pg_conn * conn=0x0000023827d8c240) Line 972 C
libpq.dll!PQsendQuery(pg_conn * conn=0x0000023827d8c240, const char * query=0x00007ffe9231f578) Line 1167 C
libpq.dll!PQexec(pg_conn * conn=0x0000023827d8c240, const char * query=0x00007ffe9231f578) Line 1850 C
libpqxx.dll!pqxx::connection_base::Exec(const char * Query=0x00007ffe9231f578, int Retries=0) Line 723 C++
libpqxx.dll!pqxx::internal::gate::connection_transaction::Exec(const char * query=0x00007ffe9231f578, int retries=0) Line 18 C++
libpqxx.dll!pqxx::transaction_base::DirectExec(const char * C=0x00007ffe9231f578, int Retries=0) Line 409 C++
libpqxx.dll!pqxx::basic_transaction::do_commit() Line 41 C++
libpqxx.dll!pqxx::transaction_base::commit() Line 164 C++

Also let me highlight the fact that the crash do not occure when the SSL is not configured. 
As you suggested on your bugreport page I would not like to guess the issues, but at first I thought the issue is happening because of the SSL version, so I wrote a bug report to them also. (Link: https://github.com/openssl/openssl/issues/6393) where they suggested the following:
Then probably you need to first raise this issue with the postgres folks. The most likely cause of this issue is a problem with those locking callbacks.

Let me know if you need more info.

Best Regards,
Adam Maracska 

pgsql-bugs by date:

Previous
From: Jeff Janes
Date:
Subject: Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead
Next
From: PG Bug reporting form
Date:
Subject: BUG #15227: Planner often ignores covering indexes (with includeclause)