2020年7月8日
vfprintf.c: No such file or directory.
void BaseLog::Error(const char * format, ...) { if (!isShow(ERROR)) return; va_list vp; int cnt; char strLog[MAX_LOGLINE_LEN]; va_start(vp, format); cnt = vsnprintf(strLog, sizeof(strLog)-1, format, vp); va_end(vp); LogLine line(ERROR, strLog); WriteLog(line); }
Program received signal SIGSEGV, Segmentation fault. 0xb7c70163 in _IO_vfprintf_internal (s=s@entry=0xbfff9f10, format=<optimized out>, format@entry=0x810aeef "%d%s", ap=0xbffff500 "\340\256\020\ba\260÷T\346Y\267\220\364\377\277", ap@entry=0xbffff4f8 "U5&\032\b\003") at vfprintf.c:1661 1661 vfprintf.c: No such file or directory. (gdb) bt #0 0xb7c70163 in _IO_vfprintf_internal (s=s@entry=0xbfff9f10, format=<optimized out>, format@entry=0x810aeef "%d%s", ap=0xbffff500 "\340\256\020\ba\260÷T\346Y\267\220\364\377\277", ap@entry=0xbffff4f8 "U5&\032\b\003") at vfprintf.c:1661 #1 0xb7c8ffa3 in _IO_vsnprintf (string=0xbfffa044 "438711637", maxlen=<optimized out>, format=0x810aeef "%d%s", args=0xbffff4f8 "U5&\032\b\003") at vsnprintf.c:119 #2 0x08089621 in BaseLog::Error (this=0xbffff534, format=0x810aeef "%d%s") at LogUtil.cpp:107
查了半天,问题出在调用处:
log->Error("%d%s", 3333333333333, "ssssssssssssss"); // 错误,整型溢出