Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1468084 - undefined symbol my_progname in libnetsnmptrapd.so
Summary: undefined symbol my_progname in libnetsnmptrapd.so
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: net-snmp
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Josef Ridky
QA Contact: David Jež
URL:
Whiteboard:
Depends On:
Blocks: 1470004
TreeView+ depends on / blocked
 
Reported: 2017-07-06 01:39 UTC by k-endou
Modified: 2019-08-06 13:08 UTC (History)
4 users (show)

Fixed In Version: net-snmp-5.7.2-39.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1470004 (view as bug list)
Environment:
Last Closed: 2019-08-06 13:08:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
patch with solution (1.26 KB, patch)
2017-07-12 09:09 UTC, Josef Ridky
no flags Details | Diff
better patch (1020 bytes, patch)
2017-07-20 18:06 UTC, Adam Williamson
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2239 0 None None None 2019-08-06 13:08:57 UTC

Description k-endou 2017-07-06 01:39:15 UTC
Description of problem:
When I was trying to run a perl script which uses NetSNMP::TrapReceiver module,
I found the script aborts with an "undefined symbol" error.
The error message was:
Can't load '/usr/lib64/perl5/vendor_perl/auto/NetSNMP/TrapReceiver/TrapReceiver.so' for module NetSNMP::TrapReceiver: /lib64/libnetsnmptrapd.so.31: undefined symbol: my_progname at /usr/lib64/perl5/DynaLoader.pm line 190.

Version-Release number of selected component (if applicable):
net-snmp-perl-5.7.2-24.el7_2.1.x86_64
net-snmp-agent-libs-5.7.2-24.el7_2.1.x86_64

How reproducible:
always when perl loads NetSNMP::TrapReceiver module

Steps to Reproduce:
1. execute "perl -MNetSNMP::TrapReceiver -e1"

Actual results:
aborts with the error message:
Can't load '/usr/lib64/perl5/vendor_perl/auto/NetSNMP/TrapReceiver/TrapReceiver.so' for module NetSNMP::TrapReceiver: /lib64/libnetsnmptrapd.so.31: undefined symbol: my_progname at /usr/lib64/perl5/DynaLoader.pm line 190.
 at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.

Expected results:
exits with no messages.

Additional info:
This seems caused by libnetsnmptrapd.so not linked dynamically to an appropriate mysql/mariadb library ( probably libmysqlclient.so ).
Because, no mysql/mariadb related library files appears in output of "ldd" command although libnetsnmptrapd.so contains some "my_*" or "mysql_*" symbols, which shown in "readelf -a".

Anyway, I also found a workaround to this problem.
Preloading libmysqlclient.so with "LD_PRELOAD" environment variable suppresses this error, and the script I tried runs normally now.
ex. $ LD_PRELOAD=/usr/lib64/mysql/libmysqlclient.so.18 perl -MNetSNMP::TrapReceiver -e1

Comment 2 Petr Pisar 2017-07-11 13:08:40 UTC
# ldd -r /usr/lib64/perl5/vendor_perl/auto/NetSNMP/TrapReceiver/TrapReceiver.so
[...]
undefined symbol: my_progname   (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_close   (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_error      (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_autocommit      (/lib64/libnetsnmptrapd.so.31)
undefined symbol: load_defaults (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_init       (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_prepare    (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_close      (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_real_connect    (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_commit  (/lib64/libnetsnmptrapd.so.31)
undefined symbol: my_init       (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_error   (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_bind_param (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_server_end      (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_sqlstate   (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_sqlstate        (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_errno   (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_init    (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_execute    (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_stmt_errno      (/lib64/libnetsnmptrapd.so.31)
undefined symbol: mysql_insert_id       (/lib64/libnetsnmptrapd.so.31)

From net-snmp build log:

libtool: link: gcc -shared  -fPIC -DPIC  .libs/snmptrapd_handlers.o .libs/snmptrapd_log.o .libs/snmptrapd_auth.o .libs/snmptrapd_sql.o   -L/builddir/build/BUILD/net-snmp-5.7.2/agent/.libs -L/builddir/build/BUILD/net-snmp-5.7.2/snmplib/.libs ../agent/.libs/libnetsnmpmibs.so -L/usr/lib64/perl5/CORE /builddir/build/BUILD/net-snmp-5.7.2/agent/.libs/libnetsnmpagent.so -lwrap /builddir/build/BUILD/net-snmp-5.7.2/snmplib/.libs/libnetsnmp.so -lsensors -lrpm -lrpmio ../snmplib/.libs/libnetsnmp.so -lssl -lcrypto -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc  -O2 -fstack-protector-strong -m64 -mtune=generic -fstack-protector -Wl,--enable-new-dtags -Wl,-rpath -Wl,/usr/lib64/perl5/CORE -fstack-protector -Wl,-z -Wl,relro -Wl,-z -Wl,now   -Wl,-soname -Wl,libnetsnmptrapd.so.31 -o .libs/libnetsnmptrapd.so.31.0.2

The symbols are indeed provided by libmysqlclient.so and the path is added into ld-linux.so configuration by file /etc/ld.so.conf.d/mariadb-x86_64.conf.

So the only missing piece is $(mysql_config --libs) option to the libnetsnmptrapd.so.31.0.2's linker command.

Obviously upstream thinks that plugins does not need explicit linkage <https://sourceforge.net/p/net-snmp/bugs/1563/>.

I think this is a bug in net-snmp build script.

Comment 3 Josef Ridky 2017-07-12 09:09:21 UTC
Created attachment 1296787 [details]
patch with solution

Comment 4 Adam Williamson 2017-07-20 17:17:27 UTC
That patch really doesn't seem like the right way to fix this. The only way I can think it might work is that it effectively results in that definition of LIBS getting 'leaked' out of the configure step, such that *everything* in the entire build process likely winds up getting linked against libmysqlclient / libmariadb .

Wouldn't a more appropriate fix be to change the rule for libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION) in apps/Makefile.in ?

Comment 5 Adam Williamson 2017-07-20 18:06:01 UTC
Created attachment 1301954 [details]
better patch

I think this patch is more correct; it adds MYSQL_LIBS to the linking of libnetsnmptrapd. The other patch results in 21 occurrences of -lmariadb in the build process, including linking some libraries against libmariadb that do not *need* to be linked against it at all; this patch results in 8 occurrences of -lmariadb , but still fixes the bug (at least, the ldd command no longer reports any unresolved symbols).

Comment 6 Adam Williamson 2017-07-20 18:12:26 UTC
Filed upstream https://sourceforge.net/p/net-snmp/bugs/2792/ with my patch. I'm doing a Fedora Rawhide build with my patch, too.

Comment 11 errata-xmlrpc 2019-08-06 13:08:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2239


Note You need to log in before you can comment on or make changes to this bug.