Segmentation fault when executing gsmd

Sean Chiang sean_chiang at openmoko.com
Tue Aug 21 15:16:37 CEST 2007


Hi all,

I just checked out the latest gsmd source from svn. While I executed the
gsmd in gta01,  I
can't get respond when send at command through libgsm-tool utility.

Below are the logs for gsmd and libgsm-tool respectively.

<%
...
Thu Jan  1 00:06:51 1970 <1> atcmd.c:415:ml_parse() Clearing mlbuf
Thu Jan  1 00:06:51 1970 <1> atcmd.c:210:ml_parse() buf=`%CSQ: 1 '(8)
Thu Jan  1 00:06:51 1970 <1> atcmd.c:372:ml_parse() Appending buf to mlbuf
Thu Jan  1 00:11:50 1970 <1> gsmd.c:124:alive_interval_tmr_cb() interval
expired, starting next alive inquiry
Thu Jan  1 00:11:50 1970 <1> atcmd.c:545:atcmd_submit() submitting
command `AT'
Thu Jan  1 00:12:20 1970 <1> gsmd.c:79:alive_tmr_cb() gsmd_alive timer
expired
Thu Jan  1 00:12:20 1970 <8> gsmd.c:82:alive_tmr_cb() modem dead!
%>

<%
at
STR=`at'
RSTR=`'
ERROR reding from gsm_fd
%>

After this, I use strace to trace the gsmd, and I got SIGSEGV signal

<%
...
write(2, "buf=`%CSQ: 1 \'(8)\n", 18buf=`%CSQ: 1 '(8)
)    = 18
time(NULL)                              = 1305
write(2, "Thu Jan  1 00:21:45 1970 <1> atc"..., 52Thu Jan  1 00:21:45
1970 <1> atcmd.c:372:ml_parse() ) = 52
write(2, "Appending buf to mlbuf\n", 23Appending buf to mlbuf
) = 23
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
sigreturn()                             = ? (mask now [INT])
...
%>

And using gdbserver+gdb, I found that it seems that we didn't to
allocate memory for g->mlbuf.

<%
...
(gdb) b 375
Breakpoint 1 at 0xc1f0: file atcmd.c, line 375.
(gdb) target remote 192.168.0.202:4444
Remote debugging using 192.168.0.202:4444
0x40000950 in ?? () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Breakpoint 1, ml_parse (buf=0x2370c "%CSQ: 1 ", len=4, ctx=0x236b8)
    at atcmd.c:375
375             memcpy(g->mlbuf + g->mlbuf_len, buf, len);
(gdb) p g->mlbuf
$1 = (unsigned char *) 0x0
(gdb) p g->mlbuf_len
$2 = 0
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x400acfa0 in ?? ()
(gdb)

%>

Regards,
-Sean Chiang



More information about the gsmd-devel mailing list