Segmentation Fault of application using va_list

onetarget at sina.com onetarget at sina.com
Fri Jan 26 19:54:25 EST 2007


Dear all,
    I am now using ELDK-3.1.1 with MPC8270 board, the
kernel is 2.4.25. There is  an application which will output some
log messages, the code segment is as follows:
void mlogv(int pri, const char *fmt, va_list ap)
{
        char *myfmt;
        int logfile = 0;
         int fg = 1;
        myfmt = mlog_common( fmt);
        if (fg)
               
vprintf(myfmt, ap);  /* Segment Fault occurs here */
        if (logfile)
                log_vaprint( newfmt, ap);
        else
                vsyslog(LOG_ALERT, newfmt, ap);
}
void
void mlog(const char *fmt, ...)
{
        va_list ap;
        va_start(ap, fmt);
        mlogv(fmt, ap);
        va_end(ap);
}
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.
But, when I commented out these 2 lines:
if (fg)        vprintf(myfmt, ap);
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, 
__STDIO_INLINE int
vprintf (__const char *__restrict __fmt, _G_va_list __arg) __THROW
{
  return vfprintf (stdout, __fmt, __arg);
}
    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.
    Would you like to help me with it?
    Thank you and regards,
            W.Target
        Jan-26-2007

-------------------------------------------------------------------
惠普商用台式机dc5750,高性能,低功耗!( http://ad4.sina.com.cn/sina/limeng3/mail_zhuiyu/2006/mail_zhuiyu_20061225.html )

===================================================================
注册新浪2G免费邮箱( http://mail.sina.com.cn/chooseMode.html )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20070126/8458ae87/attachment.htm 


More information about the Linuxppc-embedded mailing list