Hi,
I have a problem , it's a segmentation fault, when i use json_pack(). I don't known whether it's a bug of "strlen-sse2-bsf"
dev environtment:
ubuntu 12.04 LTS(x86 32bit)
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
jansson 2.3.1
code:
int add_elem_to_dotclock(json_t * root, json_t *record, int id, \
time_t time1, time_t time2, int flag){
if(root == NULL || record == NULL) {
printf("json handle is NULL.\n");
return -1;
}
int retval;
json_t *obj_elem;
if((obj_elem = json_object()) == NULL) {
printf("create json object failed.\n");
return -1;
}
obj_elem = json_pack("{si,sI,sI}", "id", id, "time1", time1, "time2", time2);
if(obj_elem == NULL) {
printf("json_pack() error.\n");
json_decref(obj_elem);
return -1;
} /* error with json_pack() */
if(flag == 1) { /* fill first empty elem */
if(json_array_set_new(record, 0, obj_elem) == -1){
json_decref(obj_elem);
return -1;
}
}else {
if(json_array_append_new(record, obj_elem) == -1){
json_decref(obj_elem);
return -1;
}
}
retval = json_object_set_new(root, VIDEO_ID, record);
if(retval) {
printf("json_object_set_new() failed.\n");
return -1;
}
// json_decref(obj_elem);
return 0;
}
gdb bt info:
xubh@zjnblh:~/snmedia/nbhd_server_thread$ gdb -c core ./nbhd_server_thread
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<
http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/xubh/snmedia/nbhd_server_thread/nbhd_server_thread...done.
warning: core file may not match specified executable file.
[New LWP 10873]
[New LWP 10874]
[New LWP 10869]
[New LWP 10871]
[New LWP 10866]
[New LWP 10867]
[New LWP 10870]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `./nbhd_server_thread'.
Program terminated with signal 11, Segmentation fault.
#0 __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:51
51 ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S: No such file or directory.
(gdb) bt
#0 __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:51
#1 0xb76b4ee4 in utf8_check_string (string=0x5080e81a <Address 0x5080e81a out of bounds>, length=-1) at utf.c:170
#2 0xb76b3ff1 in pack_object (ap=0xb47b8bbc, s=0xb47b8ba0) at pack_unpack.c:114
#3 pack (s=0xb47b8ba0, ap=0xb47b8bbc) at pack_unpack.c:175
#4 0xb76b4365 in json_vpack_ex (error=0x0, flags=0, fmt=0x80de869 "{si, sI, sI}", ap=0xb47b8bf4 "f\350\r\b\001") at pack_unpack.c:547
#5 0xb76b4493 in json_pack (fmt=0x80de869 "{si, sI, sI}") at pack_unpack.c:581
#6 0x08054bb0 in add_elem_to_dotclock (root=0xb5202e18, record=0xb5202880, id=1, time1=1350625215, time2=1350625306, flag=0) at json_utils.cpp:1191
#7 0x08052005 in hd_worker (arg=0x810cc40) at worker.cpp:237
#8 0xb76c1d4c in start_thread (arg=0xb47b9b40) at pthread_create.c:308
#9 0xb74c3d3e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
(gdb)