Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba412c9

Browse files
committed
Avoid ecpglib core dump with out-of-order operations.
If an application executed operations like EXEC SQL PREPAREwithout having first established a database connection, it couldget a core dump instead of the expected clean failure. Thisoccurred because we did "pthread_getspecific(actual_connection_key)"without ever having initialized the TSD key actual_connection_key.The results of that are probably platform-specific, but at leaston Linux it often leads to a crash.To fix, add calls to ecpg_pthreads_init() in the code paths thatmight use actual_connection_key uninitialized. It's harmless(and hopefully inexpensive) to do that more than once.Per bug #17514 from Okano Naoki. The problem's ancient, soback-patch to all supported branches.Discussion:https://postgr.es/m/17514-edd4fad547c5692c@postgresql.org
1 parentd26ac35 commitba412c9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ ecpg_get_connection_nr(const char *connection_name)
4040
if ((connection_name==NULL)|| (strcmp(connection_name,"CURRENT")==0))
4141
{
4242
#ifdefENABLE_THREAD_SAFETY
43+
ecpg_pthreads_init();/* ensure actual_connection_key is valid */
44+
4345
ret=pthread_getspecific(actual_connection_key);
4446

4547
/*
4648
* if no connection in TSD for this thread, get the global default
4749
* connection and hope the user knows what they're doing (i.e. using
4850
* their own mutex to protect that connection from concurrent accesses
4951
*/
50-
/* if !ret then we got the connection from TSD */
51-
if (NULL==ret)
52+
if (ret==NULL)
5253
/* no TSD connection, going for global */
5354
ret=actual_connection;
5455
#else
@@ -78,15 +79,16 @@ ecpg_get_connection(const char *connection_name)
7879
if ((connection_name==NULL)|| (strcmp(connection_name,"CURRENT")==0))
7980
{
8081
#ifdefENABLE_THREAD_SAFETY
82+
ecpg_pthreads_init();/* ensure actual_connection_key is valid */
83+
8184
ret=pthread_getspecific(actual_connection_key);
8285

8386
/*
8487
* if no connection in TSD for this thread, get the global default
8588
* connection and hope the user knows what they're doing (i.e. using
8689
* their own mutex to protect that connection from concurrent accesses
8790
*/
88-
/* if !ret then we got the connection from TSD */
89-
if (NULL==ret)
91+
if (ret==NULL)
9092
/* no TSD connection here either, using global */
9193
ret=actual_connection;
9294
#else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp