2008年4月24日 星期四

eXosip2 segementation fault experience

I had ever installed the osip2/eXosip2 library to test my program, but it always cause the Segmentation fault while I am running my sip user agent program.

The osip2/eXosip2 library versions are as follows:
osip2: libosip2-3.0.3-2
eXosip2: libeXosip2-3.0.3-3

The libraries include libeXosip2, libosip2, libosipparser2 as follow listing
# ls -la /usr/lib/libosip* /usr/lib/libeXosip2.* | awk '{print $8}'
/usr/lib/libeXosip2.a
/usr/lib/libeXosip2.la
/usr/lib/libeXosip2.so
/usr/lib/libeXosip2.so.4
/usr/lib/libeXosip2.so.4.2.0
/usr/lib/libosip2.a
/usr/lib/libosip2.la
/usr/lib/libosip2.so
/usr/lib/libosip2.so.2
/usr/lib/libosip2.so.2.2.0
/usr/lib/libosipparser2.a
/usr/lib/libosipparser2.la
/usr/lib/libosipparser2.so
/usr/lib/libosipparser2.so.2
/usr/lib/libosipparser2.so.2.2.0


When I run the sip ua program, it will cause Segmentation fault while receive the SIP reply message "407 Proxy Authentication Required".

SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP
[Other sip headers are omitted]

| INFO1 | Message received from: A.B.C.D:5060
| INFO1 | Message received from: A.B.C.D:5060
| INFO3 | MESSAGE REC. CALLID:951246000
| INFO1 | Message received from: A.B.C.D:5060
| INFO3 | cb_rcv4xx (id=1)
| INFO2 | eXosip: timer sec:5 usec:10000!

Segmentation fault (core dumped)

The gdb bt (backtrace) dumping is listed below

Program terminated with signal 11, Segmentation fault.
#0 0x0015298c in osip_trace@plt () from /usr/lib/libeXosip2.so.4
(gdb) bt
#0 0x0015298c in osip_trace@plt () from /usr/lib/libeXosip2.so.4
#1 0x0016e722 in __eXosip_create_proxy_authorization_header (wa=0x9eab608, rquri=0x9eab940 "sip:d-life.org",
username=0x9ea71e2 "admin", passwd=0x9ea7214 "openserrw", ha1=0x9ea7246 "", auth=0xbfd87dac,
method=0x9eaa258 "REGISTER", pCNonce=0x17cd9d "0a4f113b", iNonceCount=1) at jauth.c:484
#2 0x001556c9 in eXosip_add_authentication_information (req=0x9eaa268, last_response=0x9eab3a0) at eXosip.c:1248
#3 0x00158952 in _eXosip_register_build_register (jr=0x9ea72b8, _reg=0xbfd87e94) at eXregister_api.c:145
#4 0x00158e48 in eXosip_register_send_register (rid=1, reg=0x0) at eXregister_api.c:294
#5 0x001531ca in _eXosip_retry_register_with_auth (je=0x9eaa7f8) at eXosip.c:255
#6 0x0015362b in eXosip_retry_with_auth (je=0x9eaa7f8) at eXosip.c:385
#7 0x001538a6 in eXosip_default_action (je=0x9eaa7f8) at eXosip.c:450
#8 0x0804b704 in main (argc=3, argv=0xbfd8a014) at sip8d.c:139

The Segmentation fault is caused by the signal 11 (SIGSEGM), and was triggered from the eXosip2 eXosip_default_action api (frame 7). And the error reference seems to happen in the osip2/osipparser2 library (frame 1).

definition of /usr/include/bits/signum.h (some pieces of the definition)
/* Signals. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
#define SIGILL 4 /* Illegal instruction (ANSI). */
#define SIGTRAP 5 /* Trace trap (POSIX). */
#define SIGABRT 6 /* Abort (ANSI). */
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
#define SIGBUS 7 /* BUS error (4.2 BSD). */
#define SIGFPE 8 /* Floating-point exception (ANSI). */
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
#define SIGPIPE 13 /* Broken pipe (POSIX). */
#define SIGALRM 14 /* Alarm clock (POSIX). */
#define SIGTERM 15 /* Termination (ANSI). */

From frame 0, we can know that libeXosip2 seems something wrong with the osip_trace

But I can not get the idea (help?) from the frame 0 of the gdb backtrace. beacause when I try to list the original source code of backtrace frame 0. It just show me the
original code of the sip user agent.
(gdb) f 0
#0 0x0015298c in osip_trace@plt () from /usr/lib/libeXosip2.so.4
(gdb) list
4 */
5
6
7 int main (int argc, char *argv[])
8 {
9 sipconf *sc;
10 siprunconf *sr;
11
12 char buf[ML], tmp[ML];
13 int ch, i, call=0;

Another point, we can show the member libraries of the libeXosip2 shared library by using nm.

# nm -l -o /usr/lib/libeXosip2.so.4 | grep osip_trace
/usr/lib/libeXosip2.so.4: U osip_trace

Here we can discover that osip_trace is an undefined symbol (reference to the nm man page, "U" The symbol is undefined)

The final solution was using the newest library of the osip2/eXosip2 libraries as follow listing

Correct libraries combination (No segmentation fault)
osip2: libosip2-3.1.0
eXosip2: libeXosip2-3.1.0

Error libraries combination (Cause the segmentation fault)
osip2: libosip2-3.0.3-2
eXosip2: libeXosip2-3.0.3-3

I guess the possible reason was that osip2 and eXosip2 library have something dependency that library version number must the same to guarantee the proper working. Because the eXosip2 library is based on the osip2 library stack to develop. Maybe the eXosip2 developers doesn't consider the backward compatibility very carefully to cause this segmentation fault condition.

沒有留言: