summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane2017-04-15 03:50:16 +0000
committerTom Lane2017-04-15 03:50:16 +0000
commit32470825d36d99a81347ee36c181d609c952c061 (patch)
tree0fe8bfc11dbb20ae8dfe943632674cd3bc859b79 /src/backend/utils
parent5a617ab3e691aec56725960e6d28c98c8af6ddaa (diff)
Avoid passing function pointers across process boundaries.
We'd already recognized that we can't pass function pointers across process boundaries for functions in loadable modules, since a shared library could get loaded at different addresses in different processes. But actually the practice doesn't work for functions in the core backend either, if we're using EXEC_BACKEND. This is the cause of recent failures on buildfarm member culicidae. Switch to passing a string function name in all cases. Something like this needs to be back-patched into 9.6, but let's see if the buildfarm likes it first. Petr Jelinek, with a bunch of basically-cosmetic adjustments by me Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/fmgr/dfmgr.c15
-rw-r--r--src/backend/utils/fmgr/fmgr.c2
2 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index 94d7dac94ce..9739c4c1447 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -91,7 +91,7 @@ static const Pg_magic_struct magic_data = PG_MODULE_MAGIC_DATA;
* at less cost than repeating load_external_function.
*/
PGFunction
-load_external_function(char *filename, char *funcname,
+load_external_function(const char *filename, const char *funcname,
bool signalNotFound, void **filehandle)
{
char *fullname;
@@ -108,8 +108,12 @@ load_external_function(char *filename, char *funcname,
if (filehandle)
*filehandle = lib_handle;
- /* Look up the function within the library */
- retval = (PGFunction) pg_dlsym(lib_handle, funcname);
+ /*
+ * Look up the function within the library. According to POSIX dlsym()
+ * should declare its second argument as "const char *", but older
+ * platforms might not, so for the time being we just cast away const.
+ */
+ retval = (PGFunction) pg_dlsym(lib_handle, (char *) funcname);
if (retval == NULL && signalNotFound)
ereport(ERROR,
@@ -155,9 +159,10 @@ load_file(const char *filename, bool restricted)
* Return (PGFunction) NULL if not found.
*/
PGFunction
-lookup_external_function(void *filehandle, char *funcname)
+lookup_external_function(void *filehandle, const char *funcname)
{
- return (PGFunction) pg_dlsym(filehandle, funcname);
+ /* as above, cast away const for the time being */
+ return (PGFunction) pg_dlsym(filehandle, (char *) funcname);
}
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 68d2110890a..d9e3bf240db 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -381,7 +381,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
* pg_proc.
*/
const Pg_finfo_record *
-fetch_finfo_record(void *filehandle, char *funcname)
+fetch_finfo_record(void *filehandle, const char *funcname)
{
char *infofuncname;
PGFInfoFunction infofunc;