[AGENT++] SIGSEGV when linking without explicit reference to shared library

Joan Ametller joan.ametller at gtd.eu
Tue Aug 1 15:04:15 CEST 2017


Hello Again,

It was my fault as I made a mistake with the linking order of the libraries.

Sorry,

-----Mensaje original-----
De: AGENTPP [mailto:agentpp-bounces at agentpp.org] En nombre de Joan Ametller
Enviado el: martes, 1 de agosto de 2017 14:46
Para: agentpp at agentpp.org
Asunto: [AGENT++] SIGSEGV when linking without explicit reference to shared library

Hello,

 

I am evaluating the library for using it in a specific project and I found a problem with the examples:

 

I run on a Linux system based on Centos7.

Libraries snmp++ and agent++ correctly installed in /usr/local

 

I made my own makefile to compile agent++ cmd_exe example, which basically does the following steps:

 

g++ -pthread -Iinclude -I/usr/local/include/ -g -D_GNU_SOURCE
-D_XOPEN_SOURCE=XPG6 -c src/agent.cpp -o src/agent.o

g++ -pthread -Iinclude -I/usr/local/include/ -g -D_GNU_SOURCE
-D_XOPEN_SOURCE=XPG6 -c src/cmd_exe_mib.cpp -o src/cmd_exe_mib.o

g++ -pthread -Iinclude -I/usr/local/include/ -g -D_GNU_SOURCE
-D_XOPEN_SOURCE=XPG6 src/agent.o src/cmd_exe_mib.o -o agent -lsnmp++
-lagent++

 

This binary crashes (SIGSEGV) and looking at gdb the output of the backtrace is the following one:

Using host libthread_db library "/lib64/libthread_db.so.1".

 

Program received signal SIGSEGV, Segmentation fault.

0x00007ffff75b837a in ?? () from /lib64/libstdc++.so.6

Missing separate debuginfos, use: debuginfo-install
glibc-2.17-157.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64
krb5-libs-1.14.1-26.el7.x86_64 libcom_err-1.42.9-9.el7.x86_64
libgcc-4.8.5-11.el7.x86_64 libselinux-2.5-6.el7.x86_64
libstdc++-4.8.5-11.el7.x86_64 openssl-libs-1.0.1e-60.el7.x86_64
pcre-8.32-15.el7_2.1.x86_64 zlib-1.2.7-17.el7.x86_64

(gdb) bt

#0  0x00007ffff75b837a in ?? () from /lib64/libstdc++.so.6

#1  0x00007ffff7b96be6 in operator-- (this=<synthetic pointer>) at
/usr/include/c++/4.8.2/bits/stl_tree.h:204

#2  std::_Rb_tree<std::string, std::pair<std::string const, int*>, std::_Select1st<std::pair<std::string const, int*> >, std::less<std::string>, std::allocator<std::pair<std::string const, int*> >
>::_M_get_insert_unique_pos (

    this=this at entry=0x7ffff7ddc720 <logfilter_profiles>, __k="off") at
/usr/include/c++/4.8.2/bits/stl_tree.h:1333

#3  0x00007ffff7b96ddb in std::_Rb_tree<std::string, std::pair<std::string const, int*>, std::_Select1st<std::pair<std::string const, int*> >, std::less<std::string>, std::allocator<std::pair<std::string const, int*> >
>::_M_get_insert_hint_unique_pos (

    this=this at entry=0x7ffff7ddc720 <logfilter_profiles>, __position=...,
__k="off") at /usr/include/c++/4.8.2/bits/stl_tree.h:1441

#4  0x00007ffff7b96e99 in std::_Rb_tree<std::string, std::pair<std::string const, int*>, std::_Select1st<std::pair<std::string const, int*> >, std::less<std::string>, std::allocator<std::pair<std::string const, int*> >
>::_M_insert_unique_ (

    this=this at entry=0x7ffff7ddc720 <logfilter_profiles>, __position=..., __position at entry=..., __v=...) at
/usr/include/c++/4.8.2/bits/stl_tree.h:1478

#5  0x00007ffff7b9621f in insert (__x=..., __position=...,
this=0x7ffff7ddc720 <logfilter_profiles>) at
/usr/include/c++/4.8.2/bits/stl_map.h:648

#6  operator[] (__k="off", this=0x7ffff7ddc720 <logfilter_profiles>) at
/usr/include/c++/4.8.2/bits/stl_map.h:469

#7  initLogProfiles () at log.cpp:80

#8  Snmp_pp::DefaultLog::init_ts (logger=0x0) at log.cpp:443

#9  0x00007ffff791031d in log () at /usr/local/include/snmp_pp/log.h:539

#10 Agentpp::Synchronized::Synchronized (this=0x7ffff7b67a20
<Agentpp::ThreadManager::global_lock>) at threads.cpp:144

#11 0x00007ffff78b8346 in __static_initialization_and_destruction_0
(__initialize_p=1, __priority=65535) at threads.cpp:35

#12 _GLOBAL__sub_I_threads.cpp(void) () at threads.cpp:1259

#13 0x00007ffff7dec1e3 in _dl_init_internal () from
/lib64/ld-linux-x86-64.so.2

#14 0x00007ffff7dde21a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2

#15 0x0000000000000001 in ?? ()

#16 0x00007fffffffe5a6 in ?? ()

#17 0x0000000000000000 in ?? ()

(gdb)

 

However, if I link adding explicit reference to agent++ shared library.

 

g++ -pthread -Iinclude -I/usr/local/include/ -g -D_GNU_SOURCE
-D_XOPEN_SOURCE=XPG6 src/agent.o src/cmd_exe_mib.o /usr/local/lib/libagent++.so -o agent2 -lsnmp++ -lagent++

 

[admin at sup1 end-system]$ ./agent2

20170801.14:45:19: 139869970962496: (1)EVENT  : main: SNMP listen port:
(4700)

20170801.14:45:19: 139869970962496: (1)ERROR  : getBootCounter: Could not open (file): (snmpv3_boot_counter)

20170801.14:45:19: 139869970962496: (3)INFO   : saveBootCounter: created new
file (file): (snmpv3_boot_counter)

20170801.14:45:19: 139869970962496: (5)INFO   : saveBootCounter: Saved
counter (file) (engine id) (boot): (snmpv3_boot_counter), (  80 00 13 70 05
73 75 70 31 12 5C                   ...p.sup1.\

), (1)

20170801.14:45:19: 139869970962496: (3)INFO   : AuthPriv: Added default Auth
and Priv protocols.

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index:
(11.128.0.19.112.5.115.117.112.49.18.92.12.117.110.115.101.99.117.114.101.85
.115.101.114)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.3.77.68.53)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.3.83.72.65)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.6.77.68.53.68.69.83)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.6.83.72.65.68.69.83)

20170801.14:45:19: 139869970962496: (1)ERROR  : UsmUserTable: Unsupported
privProtocol: (3)

20170801.14:45:19: 139869970962496: (1)ERROR  : UsmUserTable: Unsupported
privProtocol: (3)

20170801.14:45:19: 139869970962496: (1)ERROR  : UsmUserTable: Unsupported
privProtocol: (9)

20170801.14:45:19: 139869970962496: (1)ERROR  : UsmUserTable: Unsupported
privProtocol: (9)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.77.68.53.65.69.83.49.50.56)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.83.72.65.65.69.83.49.50.56)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.77.68.53.65.69.83.49.57.50)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.83.72.65.65.69.83.49.57.50)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.77.68.53.65.69.83.50.53.54)

20170801.14:45:19: 139869970962496: (1)DEBUG  : UsmUserTable: add row with
index: (11.128.0.19.112.5.115.117.112.49.18.92.9.83.72.65.65.69.83.50.53.54)

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

20170801.14:45:19: 139869970962496: (1)DEBUG  : TaskManager: thread started

 

It works.

 

Any Idea about why this is happening?

 

Thank you very much.

 

Joan Ametller

_______________________________________________
AGENTPP mailing list
AGENTPP at agentpp.org
https://oosnmp.net/mailman/listinfo/agentpp




More information about the AGENTPP mailing list