Re: [Log4c-devel] A coredump in log4c_category_vlog.
Brought to you by:
valtri
|
From: LeeEsther <li...@ho...> - 2015-09-02 02:07:40
|
Hi, Many thanks for your reply. My codes used a lot of macro so it becomes very complicated. And this log have many outputs. I used gcc -E to compile it. and below is output:
static char fmt__[1024];
log4c_category_log( __cat_alert, priority__, fmt__, ("TUNNEL"), (tunnel)->info.signature, (tunnel)->info.timestamp, (tunnel)->info.sequence, kTunnelProtocolNames[(tunnel)->info.protocol], // a string ( (unsigned char *) &( (tunnel)->info.src.ip) )[3], ( (unsigned char *) &( (tunnel)->info.src.ip) )[2], ( (unsigned char *) &( (tunnel)->info.src.ip) )[1], ( (unsigned char *) &( (tunnel)->info.src.ip) )[0], (tunnel)->info.src.port, // an ip ( (unsigned char *) &( (tunnel)->info.dst.ip) )[3], ( (unsigned char *) &( (tunnel)->info.dst.ip) )[2], ( (unsigned char *) &( (tunnel)->info.dst.ip) )[1], ( (unsigned char *) &( (tunnel)->info.dst.ip) )[0], (tunnel)->info.dst.port, // an ip ( (unsigned char *) &( (tunnel)->info.original_dst.ip) )[3], ( (unsigned char *) &( (tunnel)->info.original_dst.ip) )[2], ( (unsigned char *) &( (tunnel)->info.original_dst.ip) )[1], ( (unsigned char *) &( (tunnel)->info.original_dst.ip) )[0], (tunnel)->info.original_dst.port, // an ip tunnel->bytes_up, tunnel->bytes_down, // 2 long int get_local_time_short( &tunnel->time_connect ), get_local_time_short( &tunnel->time_disconnect ), // this func return a string timeval_duration_s( &tunnel->time_connect, &tunnel->time_disconnect ), // a double kNodeTypeNames[tunnel->target_type], // a string ( (unsigned char *) &(tunnel->target_ip) )[3], ( (unsigned char *) &(tunnel->target_ip) )[2], ( (unsigned char *) &(tunnel->target_ip) )[1], ( (unsigned char *) &(tunnel->target_ip) )[0], tunnel->target_port, // an ip tunnel->sync_rtt, first_down_rtt, last_down_rtt, // 3 int payload_protocol, payload_keyword, // 2 string kEndpointTypeNames[tunnel->error_role], // a string ( (tunnel->error_events & 0x10) ? "EOF:" : ""), ( (tunnel->error_events & 0x20) ? "ERROR:" : ""), (strerror( tunnel->error_code ) ), // 3 string tunnel->error_code ); // 1 int
and the format string(fmt__) is: "20150901 12:16:46.498083 src/tunnel.c:128 ] INFO: %s %08x%04x%08x %s %d.%d.%d.%d:%d %d.%d.%d.%d:%d %d.%d.%d.%d:%d %ld %ld %s %s %.2f %s %d.%d.%d.%d:%u %d %d %d %s %s %s %s%s%s %d\n"
It's output would like this:
20150902 09:56:23.433117 src/tunnel.c:128 ] INFO: TUNNEL 78ed303c5e6500002321 TCP 120.237.48.60:2001 14.17.52.180:80 14.17.52.180:80 996 1436 09:56:23.368374 09:56:23.433114 0.06 NEXTPROXY 120.24.240.90:8101 0 64 64 UDP 14.17.52.180:80 proxy EOF:Success 0
As you can see, I check every argument, and all of them is correct, but it goes dump...
And I also used '-Wall -Wformat-security' to compile my program, and it seems goint right.
The version of log4c is download in http://prdownloads.sourceforge.net/log4c/log4c-1.2.4.tar.gz
li...@ho...
From: František DvořákDate: 2015-09-01 20:18To: LiTengchaoCC: log...@li...: Re: [Log4c-devel] A coredump in log4c_category_vlog.Hello,
this could be a problem of using string message in the place, where
format string is expected in the API. For example:
Proper usage:
log4c_category_log(log4c_category_get(catName), a_priority, "%s", msg);
Problematic usage leading to crashes:
log4c_category_log(log4c_category_get(catName), a_priority, msg);
Because "msg" could contain "%" characters.
1) What looks the code at src/tunnel.c:128? (The log4c_category_log()
call?)
2) Could you try to compile your project using '-Wall -Wformat-security'
build flags and check the warnings? You will need the latest log4c
version 1.2.4 to have the format parameters check working.
Cheers,
František
On út, 2015-09-01 at 10:35 +0000, LiTengchao wrote:
> Hello,
> I am new here, but I had met a coredump and I could not find any
> error in my program. (and this situation is not occur usually). I
> search google find a similar problem(which say that string was lager
> than 1024 ) but was fixed in 1.4.2, I use 1.4.4.
> Could any one give me any support?
>
>
> below is the core file:
>
>
> Program terminated with signal 11, Segmentation fault.
> #0 0x00000030f0078c80 in strlen () from /lib64/libc.so.6
> (gdb) bt
> #0 0x00000030f0078c80 in strlen () from /lib64/libc.so.6
> #1 0x00000030f0046cf7 in vfprintf () from /lib64/libc.so.6
> #2 0x00000030f006898a in vsnprintf () from /lib64/libc.so.6
> #3 0x000000000055ce1b in sd_vsprintf ()
> #4 0x0000000000558682 in __log4c_category_vlog ()
> #5 0x00000000004c2fc4 in log4c_category_vlog (a_category=0x11eda90, a_priority=600,
> a_format=0x8e5320 "20150901 12:16:46.498083 src/tunnel.c:128 ] INFO: %s %08x%04x%08x %s %d.%d.%d.%d:%d %d.%d.%d.%d:%d %d.%d.%d.%d:%d %ld %ld %s %s %.2f %s %d.%d.%d.%d:%u %d %d %d %s %s %s %s%s%s %d\n", a_args=0x7fff22a47f40)
> at /usr/local/include/log4c/category.h:358
> #6 0x00000000004c2f6a in log4c_category_log (a_category=0x11eda90, a_priority=600,
> a_format=0x8e5320 "20150901 12:16:46.498083 src/tunnel.c:128 ] INFO: %s %08x%04x%08x %s %d.%d.%d.%d:%d %d.%d.%d.%d:%d %d.%d.%d.%d:%d %ld %ld %s %s %.2f %s %d.%d.%d.%d:%u %d %d %d %s %s %s %s%s%s %d\n") at /usr/local/include/log4c/category.h:378
> ...
> other was omitted...
>
>
> Many Thanks.
>
>
> ______________________________________________________________________
> li...@ho...
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Log4c-devel mailing list
> Log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4c-devel
|