Conflicting function name in dynamically-loaded shared library
Hi:
I am wanting to define some functions as described in section 35.9 of
the manual, "C-Language Functions." I am compiling pre-existing files
of c-code from another project into object files, and then linking
those object files into a shared library along with my own functions
that follow the posgresql calling convention, invoking other functions
as desired.
This pre-existing c-code I'm compiling happens to contain a function
named "point_add()". I see the postgresql source file fmgrtab.c also
has a function with the same name. When my code tries to invoke its
version of point_add() I get a bus error, and when I changed the name
of that function to something else the bus error went away.
Of course, since I'm working with source code I can just keep the
modified function name, but I would like to be able to keep my version
of this c code updated with that project and so to use it unmodified.
So my questions are: first, might I be wrong about the cause of this
bus error? I cannot think of another reason why changing the name of
a function would have this effect, but maybe there's some other reason
besides the "point_add()" function in fmgrtab.c conflicting. If so,
I'm interested to know.
If, however, it is probable that this bus error is a result of this
naming conflict, then do I have any options for working around it that
would enable me to use the code from this other library without
changing the name of its "point_add()" function? I know I could ask
that project's developers to change the function's name, but that
could break other code that currently uses it, and even if it didn't,
I would prefer something less intrusive on that project.
Thanks very much for any ideas about this,
--
Adam Mackler
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Adam Mackler wrote:
I am wanting to define some functions as described in section 35.9 of
the manual, "C-Language Functions." I am compiling pre-existing files
of c-code from another project into object files, and then linking
those object files into a shared library along with my own functions
that follow the posgresql calling convention, invoking other functions
as desired.This pre-existing c-code I'm compiling happens to contain a function
named "point_add()". I see the postgresql source file fmgrtab.c also
has a function with the same name. When my code tries to invoke its
version of point_add() I get a bus error, and when I changed the name
of that function to something else the bus error went away.Of course, since I'm working with source code I can just keep the
modified function name, but I would like to be able to keep my version
of this c code updated with that project and so to use it unmodified.So my questions are: first, might I be wrong about the cause of this
bus error? I cannot think of another reason why changing the name of
a function would have this effect, but maybe there's some other reason
besides the "point_add()" function in fmgrtab.c conflicting. If so,
I'm interested to know.If, however, it is probable that this bus error is a result of this
naming conflict, then do I have any options for working around it that
would enable me to use the code from this other library without
changing the name of its "point_add()" function? I know I could ask
that project's developers to change the function's name, but that
could break other code that currently uses it, and even if it didn't,
I would prefer something less intrusive on that project.
If you are on Linux, you could try the following patch:
/messages/by-id/CA+CSw_tPDYgnzCYW0S4oU0mTUoUhZ9pc7MRBPXVD-3Zbiwni9w@mail.gmail.com
Maybe that will make it work, then you know that your suspicion was correct.
But what you describe should definitely cause a problem, though
"bus error" sounds surprising to me.
Renaming one of the functions seems like the best thing to do.
It would need a convincing case (like, many people have that problem)
to get the name changed in PostgreSQL.
Yours,
Laurenz Albe
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
On Wed, Jan 28, 2015 at 11:23:15AM +0000, Albe Laurenz wrote:
If you are on Linux, you could try the following patch:
/messages/by-id/CA+CSw_tPDYgnzCYW0S4oU0mTUoUhZ9pc7MRBPXVD-3Zbiwni9w@mail.gmail.com
...
Renaming one of the functions seems like the best thing to do.
I am using FreeBSD, so RTLD_DEEPBIND is not supported by my dlopen().
However, your suggestion to rename the function seems at least as
good. Patching PostgreSQL would just mean trading difficulties when
upgrading the third-party library for difficulties when upgrading
PostgreSQL.
Thank you for the response and insight.
--
Adam Mackler
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general