RE: libpq @windows : leaked singlethread_lock makes AppVerifier unhappy

From: Першин Юрий Петрович <pershin(at)prosoftsystems(dot)ru>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: libpq @windows : leaked singlethread_lock makes AppVerifier unhappy
Date: 2020-12-19 17:40:31
Message-ID: c05d588c78d941b782c0c452f09f1a58@prosoftsystems.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi
Here is my workaround (from unit_tests.dll DLL_PROCESS_DETACH):

//3. Destroy LIBPQ!static pthread_mutex_t singlethread_lock
- 327 HMODULE hLeakedLibPQ = ::GetModuleHandleA("libpq.dll"); //libpq.dll v13.0.1.20323 (https://ftp.postgresql.org/pub/odbc/versions/msi/psqlodbc_13_00_0000.zip)
- 328 if (hLeakedLibPQ) {
- 329 void **singlethread_lock_ptr = (void **)(((BYTE *)hLeakedLibPQ) +
- 330 #ifdef _WIN64
- 331 0x484b8
- 332 #else
- 333 0x3F26C
- 334 #endif //_WIN64
- 335 );
- 336 if (*singlethread_lock_ptr) {
- 337 DeleteCriticalSection((LPCRITICAL_SECTION)(*singlethread_lock_ptr));
- 338 typedef void(*pthread_mutex_destroy)(void *mutex);
- 339 pthread_mutex_destroy freemtx = (pthread_mutex_destroy)::GetProcAddress(hLeakedLibPQ, "PQfreemem");
- 340 assert(freemtx != NULL);
- 341 if (freemtx) freemtx(*singlethread_lock_ptr);
- 342 }
- 343 }

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-12-19 19:39:27 v10 release notes for extended stats
Previous Message Bruce Momjian 2020-12-19 16:58:37 Re: Proposed patch for key managment