Segmentation Fault of application using va_list

onetarget at onetarget at
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);
                vsyslog(LOG_ALERT, newfmt, ap);
void mlog(const char *fmt, ...)
        va_list ap;
        va_start(ap, fmt);
        mlogv(fmt, 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, 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
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,

惠普商用台式机dc5750,高性能,低功耗!( )

注册新浪2G免费邮箱( )
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Linuxppc-embedded mailing list