happyfish100 / libfastcommon

c common functions library extracted from my open source project FastDFS. this library is very simple and stable. functions including: string, logger, chain, hash, socket, ini file reader, base64 encode / decode, url encode / decode, fast timer, skiplist, object pool etc. detail info please see the c header files.
http://bbs.chinaunix.net/forum-240-1.html
GNU Lesser General Public License v3.0
900 stars 529 forks source link

关于日志模块sprintf段错误 #53

Open JCeYing opened 1 week ago

JCeYing commented 1 week ago

0 0x00007ffff4dd0a4a in GIIO_str_overflow () from /lib64/libc.so.6

1 0x00007ffff4dcf031 in GIIO_default_xsputn () from /lib64/libc.so.6

2 0x00007ffff4d9a707 in vfprintf () from /lib64/libc.so.6

3 0x00007ffff4dc34cb in vsprintf () from /lib64/libc.so.6

4 0x00007ffff4da5617 in sprintf () from /lib64/libc.so.6

5 0x00007ffff5d9c35c in doLogEx (bNeedLock=, bNeedSync=, text_len=, text=, caption=,

tv=<optimized out>, pContext=<optimized out>) at logger.c:1039

6 log_it_ex2 (pContext=pContext@entry=0x7ffff5fd6ca0 , caption=caption@entry=0x7ffff5dc135b "ERROR",

text=text@entry=0x7fffffffd5e0 "file: tracker_client.c, line: 920, tracker server 192.168.1.231:22122 response data length: 40 is invalid, expect length: 70",
text_len=<optimized out>, bNeedSync=bNeedSync@entry=false, bNeedLock=bNeedLock@entry=true) at logger.c:1086

7 0x00007ffff5d9d71e in logError (

format=format@entry=0x7ffff5b76338 "file: tracker_client.c, line: %d, tracker server %s:%u response data length: %ld is invalid, expect length: %d") at logger.c:1312

8 0x00007ffff5b69ecd in tracker_query_storage_store_without_group (pTrackerServer=0x777520, pStorageServer=, group_name=0x752750 <fdfsOper+16> "",

store_path_index=0x7fffffffdfcc) at tracker_client.c:918

9 0x00000000004390fa in fdfsOperator::getStorageServer (this=0x752740 ) at fdfsOperator.cpp:61

10 0x00000000004280b2 in main (argc=1, argv=0x7fffffffe258) at main.cpp:192

这是我程序段错误的堆栈信息 我之前用的是commont1.0.41版本 我现在用的是fastdfs最新版本和common最新版本还是会触发这个段错误 只要调用到doLogEx记录错误日志就会触发

happyfish100 commented 1 week ago

在 main 函数中需要先调用 log_init(); 进行初始化。 可以参阅 client/fdfs_test.c

JCeYing commented 1 week ago

在 main 函数中需要先调用 log_init();进行初始化。 可以参阅 client/fdfs_test.c

好的 感谢