I am using vsnprintf in a machine and it's not giving error but when i ran exact code spinet it's giving me error.
My machine where i am getting error on machine
Linux localhost 3.14.1-1-ARCH #1 SMP PREEMPT Mon Apr 14 20:40:47 CEST 2014 x86_64 GNU/Linux
Machine where i am not getting any error about this.
Linux arunkumar.gupta 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:19:35 UTC 2013 i686 i686 i686 GNU/Linux
Code
void
_log_message(int level, char *fmt, ...)
{
int n;
char *msg;
va_list args;
char time_string[TIME_LENGTH];
char str[STRING_LENGTH];
assert(level <= log_level);
va_start(args, fmt);
fill_time_string(time_string, TIME_LENGTH);
n = snprintf(str, STRING_LENGTH, "%-9s %s [%s:%lu]: ", log_string[level], time_string, log_ident, (long int) getpid());
msg = str + n;
n += vsnprintf(msg, STRING_LENGTH-n, fmt, args);
if(n >= STRING_LENGTH) {
strcpy(str+STRING_LENGTH-6, " ...\n");
n = STRING_LENGTH-1;
}
va_end(args);
}
Backtrace output
./a.out(handler+0x25)[0x401152]
/usr/lib/libc.so.6(+0x35400)[0x7fb0e2358400]
/usr/lib/libc.so.6(_IO_vfprintf+0x1cf0)[0x7fb0e236b1f0]
/usr/lib/libc.so.6(vsnprintf+0x79)[0x7fb0e2395459]
./a.out(_log_message+0x1b7)[0x40169c]
./a.out(csc_open+0x71)[0x401894]
./a.out(open_log_file+0x43)[0x4018e3]
./a.out(main+0x5a)[0x4019c2]
/usr/lib/libc.so.6(__libc_start_main+0xf5)[0x7fb0e2344b05]
./a.out[0x401069]
Please help me it's giving me error for Arch Linux machine( Which is 32 bit machine)and but not on Ubuntu 13.04(64 bit machine). Suggest me any alternative if possible?