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

Commit9a45a89

Browse files
committed
Avoid symbol collisions between pqsignal.c and legacy-pqsignal.c.
In the name of ABI stability (that is, to avoid a library majorversion bump for libpq), libpq still exports a version of pqsignal()that we no longer want to use ourselves. However, since that hasthe same link name as the function exported by src/port/pqsignal.c,there is a link ordering dependency determining which version willactually get used by code that uses libpq as well as libpgport.a.It now emerges that the wrong version has been used by pgbench andpsql since commit06843df rearranged their link commands. Thiscan result in odd failures in pgbench with the -T switch, since itsSIGALRM handler will now not be marked SA_RESTART. psql may havesome edge-case problems in \watch, too.Since we don't want to depend on link ordering effects anymore,let's fix this in the same spirit asb6c7cfa: use macros to changethe actual link names of the competing functions. We cannot changelegacy-pqsignal.c's exported name of course, so the victim has to besrc/port/pqsignal.c.In master, rename its exported name to be pqsignal_fe in frontend orpqsignal_be in backend. (We could perhaps have gotten away with usingthe same symbol in both cases, but since the FE and BE versions nowwork a little differently, it seems advisable to use different names.)In back branches, rename to pqsignal_fe in frontend but keep it aspqsignal in backend. The frontend change could affect third-partycode that is calling pqsignal from libpgport.a or libpgport_shlib.a,but only if the code is compiled against port.h from a different minorrelease than libpgport. Since we don't support using libpgport as ashared library, it seems unlikely that there will be such a problem.I left the backend symbol unchanged to avoid an ABI break forextensions. This means that the link ordering hazard still existsfor any extension that links against libpq. However, none of our ownextensions use both pqsignal() and libpq, and we're not making thingsany worse for third-party extensions that do.Report from Andy Fan, diagnosis by Fujii Masao, patch by me.Back-patch to all supported branches, as06843df was.Discussion:https://postgr.es/m/87msfz5qv2.fsf@163.com
1 parent2ae98ea commit9a45a89

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎src/include/port.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,12 @@ extern intpg_check_dir(const char *dir);
513513
/* port/pgmkdirp.c */
514514
externintpg_mkdir_p(char*path,intomode);
515515

516-
/* port/pqsignal.c */
516+
/* port/pqsignal.c (see also interfaces/libpq/legacy-pqsignal.c) */
517+
#ifdefFRONTEND
518+
#definepqsignal pqsignal_fe
519+
#else
520+
#definepqsignal pqsignal_be
521+
#endif
517522
typedefvoid (*pqsigfunc) (SIGNAL_ARGS);
518523
externpqsigfuncpqsignal(intsigno,pqsigfuncfunc);
519524

‎src/interfaces/libpq/legacy-pqsignal.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,16 @@
2828
* with the semantics it had in 9.2; in particular, this has different
2929
* behavior for SIGALRM than the version in src/port/pqsignal.c.
3030
*
31-
* libpq itself does not use this.
31+
* libpq itself does not use this, nor does anything else in our code.
32+
*
33+
* src/include/port.h #define's pqsignal as pqsignal_fe or pqsignal_be,
34+
* but here we want to export just plain "pqsignal". We can't rely on
35+
* port.h's extern declaration either. (The point of those #define's
36+
* is to ensure that no in-tree code accidentally calls this version.)
3237
*/
38+
#undef pqsignal
39+
externpqsigfuncpqsignal(intsigno,pqsigfuncfunc);
40+
3341
pqsigfunc
3442
pqsignal(intsigno,pqsigfuncfunc)
3543
{

‎src/port/pqsignal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ wrapper_handler(SIGNAL_ARGS)
123123
* function instead of providing potentially-bogus return values.
124124
* Unfortunately, that requires modifying the pqsignal() in legacy-pqsignal.c,
125125
* which in turn requires an SONAME bump, which is probably not worth it.
126+
*
127+
* Note: the actual name of this function is either pqsignal_fe when
128+
* compiled with -DFRONTEND, or pqsignal_be when compiled without that.
129+
* This is to avoid a name collision with libpq's legacy-pqsignal.c.
126130
*/
127131
pqsigfunc
128132
pqsignal(intsigno,pqsigfuncfunc)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp