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 1470004

Summary: undefined symbol my_progname in libnetsnmptrapd.so
Product: [Fedora] Fedora Reporter: Josef Ridky <jridky>
Component: net-snmpAssignee: Josef Ridky <jridky>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: rawhideCC: jridky, jsafrane, k-endou, ppisar, qe-baseos-security, thozza
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: net-snmp-5.7.3-16.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1468084 Environment:
Last Closed: 2017-07-17 04:52:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1468084    
Bug Blocks:    

Description Josef Ridky 2017-07-12 09:10:51 UTC
+++ This bug was initially created as a clone of Bug #1468084 +++

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

--- Additional comment from Petr Pisar on 2017-07-11 09:08:40 EDT ---

# 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.

--- Additional comment from Josef Ridky on 2017-07-12 05:09 EDT ---

Comment 1 Fedora Update System 2017-07-13 15:21:26 UTC
net-snmp-5.7.3-16.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-9b253c076a

Comment 2 Fedora Update System 2017-07-13 15:21:41 UTC
net-snmp-5.7.3-14.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-77b3ddeaaa

Comment 3 Fedora Update System 2017-07-13 15:21:48 UTC
net-snmp-5.7.3-14.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2017-de05b989aa

Comment 4 Fedora Update System 2017-07-14 19:52:56 UTC
net-snmp-5.7.3-14.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-de05b989aa

Comment 5 Fedora Update System 2017-07-14 20:26:41 UTC
net-snmp-5.7.3-14.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-77b3ddeaaa

Comment 6 Fedora Update System 2017-07-14 22:55:13 UTC
net-snmp-5.7.3-16.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-9b253c076a

Comment 7 Fedora Update System 2017-07-17 04:52:57 UTC
net-snmp-5.7.3-16.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.