<style>p{margin:0}img{border:0}</style>
<font style='font-size:12px'><font size="3">Dear all,<br>
&nbsp;&nbsp;&nbsp; I am now using ELDK-3.1.1 with MPC8270 board, the
kernel is 2.4.25. There is&nbsp; an application which will output some
log messages, the code segment is as follows:<br>
<br>
void mlogv(int pri, const char *fmt, va_list ap)<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *myfmt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int logfile = 0;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  int fg = 1;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myfmt = mlog_common( fmt);<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (fg)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
vprintf(myfmt, ap);&nbsp; /* Segment Fault occurs here */<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (logfile)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log_vaprint( newfmt, ap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vsyslog(LOG_ALERT, newfmt, ap);<br>
}<br>
<br>
void<br>
void mlog(const char *fmt, ...)<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_list ap;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_start(ap, fmt);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mlogv(fmt, ap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_end(ap);<br>
}<br>
<br>
Normally when mlog() calls mlogv(), the application will get a
Segmentation Fault. With GDB and core dump, I got that the problem is
in libc.so, strlen() can not get the string's length.<br>
<br>
But, when I commented out these 2 lines:<br>
</font><font size="3"> if (fg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vprintf(myfmt, ap);<br>
There is not Segmentation Fault, and the application can run normally.
I also tracked the vprintf, and found that it is in
/opt/eldk/ppc_6xx/usr/include/bits/stdio.h, <br>
__STDIO_INLINE int<br>
vprintf (__const char *__restrict __fmt, _G_va_list __arg) __THROW<br>
{<br>
&nbsp; return vfprintf (stdout, __fmt, __arg);<br>
}<br>
&nbsp;&nbsp;&nbsp; I am not familiar with libc, so I don't know what is
the problem, and I also search the va_list() usage on different
archtectures, but I can not solve the problem.<br>
&nbsp;&nbsp;&nbsp; Would you like to help me with it?<br>
&nbsp;&nbsp;&nbsp; Thank you and regards,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  W.Target<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  Jan-26-2007<br>
</font><font size="3"><br>
<br>
</font><style>p{margin:0}img{border:0}</style></font><br />
<br />
-------------------------------------------------------------------<br />
惠普商用台式机dc5750,高性能,低功耗!( <a href=http://ad4.sina.com.cn/sina/limeng3/mail_zhuiyu/2006/mail_zhuiyu_20061225.html target=_blank>http://ad4.sina.com.cn/sina/limeng3/mail_zhuiyu/2006/mail_zhuiyu_20061225.html</a> )<br />
<br />
===================================================================<br />
注册新浪2G免费邮箱( <a href=http://mail.sina.com.cn/chooseMode.html target=_blank>http://mail.sina.com.cn/chooseMode.html</a> )