View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001470 | FSSCP | user interface | public | 2007-08-23 10:06 | 2007-10-18 01:25 |
Reporter | jcmdev0 | Assigned To | taylor | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.6.10 | ||||
Fixed in Version | 3.6.10 | ||||
Summary | 0001470: Mismatched Error parameters. | ||||
Description | Running fs2_open outside of the data directory resulted in a segfault. I tracked it down to mismatched parameters to Error in weapons.cpp. I also noticed some memory bugs. | ||||
Tags | No tags attached. | ||||
2007-08-23 10:06
|
error_fix.diff (3,410 bytes)
The first time I ran fs2_open in Linux it segfaulted. The simple fix was to move the binary into the data directory. Firing up the debugger, it was crashing in the Error function. I tracked it down to some inverted parameters on the call to the error function. I also noticed a couple other things: + memset( &buffer ,... is clobbering the static variables, rather than clearing the buffer. + char * -> const char * on the Error and Warning functions to be type friendly to vnsprintf Index: code/globalincs/pstypes.h =================================================================== RCS file: /home/fs2source/cvsroot/fs2_open/code/globalincs/pstypes.h,v retrieving revision 2.54 diff -u -r2.54 pstypes.h --- code/globalincs/pstypes.h 22 Mar 2007 22:19:31 -0000 2.54 +++ code/globalincs/pstypes.h 23 Aug 2007 05:33:46 -0000 @@ -606,8 +606,8 @@ //This are defined in MainWin.c extern void _cdecl WinAssert(char * text,char *filename, int line); extern void LuaError(struct lua_State *L, char *format=NULL, ...); -extern void _cdecl Error( char * filename, int line, char * format, ... ); -extern void _cdecl Warning( char * filename, int line, char * format, ... ); +extern void _cdecl Error( char * filename, int line, const char * format, ... ); +extern void _cdecl Warning( char * filename, int line, const char * format, ... ); #include "osapi/outwnd.h" Index: code/weapon/weapons.cpp =================================================================== RCS file: /home/fs2source/cvsroot/fs2_open/code/weapon/weapons.cpp,v retrieving revision 2.208 diff -u -r2.208 weapons.cpp --- code/weapon/weapons.cpp 16 Aug 2007 00:45:54 -0000 2.208 +++ code/weapon/weapons.cpp 23 Aug 2007 05:33:47 -0000 @@ -3880,7 +3880,7 @@ // parse weapons.tbl if ((rval = setjmp(parse_abort)) != 0) { - Error(LOCATION, "Error parsing '%s'\r\nError code = %i.\r\n", rval, current_weapon_table); + Error(LOCATION, "Error parsing '%s'\r\nError code = %i.\r\n", current_weapon_table, rval); } else { weapon_reset_info(); Index: code/windows_stub/stubs.cpp =================================================================== RCS file: /home/fs2source/cvsroot/fs2_open/code/windows_stub/stubs.cpp,v retrieving revision 2.35 diff -u -r2.35 stubs.cpp --- code/windows_stub/stubs.cpp 22 Mar 2007 22:14:57 -0000 2.35 +++ code/windows_stub/stubs.cpp 23 Aug 2007 05:33:47 -0000 @@ -208,15 +208,15 @@ } // standard warning message -void Warning( char * filename, int line, char * format, ... ) +void Warning( char * filename, int line, const char * format, ... ) { #ifndef NDEBUG va_list args; int i; int slen = 0; - memset( &buffer, 0, sizeof(buffer) ); - memset( &buffer_tmp, 0, sizeof(buffer_tmp) ); + memset( buffer, 0, sizeof(buffer) ); + memset( buffer_tmp, 0, sizeof(buffer_tmp) ); va_start(args, format); vsnprintf(buffer_tmp, sizeof(buffer_tmp) - 1, format, args); @@ -247,14 +247,14 @@ } // fatal error message -void Error( char * filename, int line, char * format, ... ) +void Error( char * filename, int line, const char * format, ... ) { - va_list args; int i; int slen = 0; + va_list args; - memset( &buffer, 0, sizeof(buffer) ); - memset( &buffer_tmp, 0, sizeof(buffer_tmp) ); + memset( buffer, 0, sizeof(buffer) ); + memset( buffer_tmp, 0, sizeof(buffer_tmp) ); va_start(args, format); vsnprintf(buffer_tmp, sizeof(buffer_tmp) - 1, format, args); |
|
Thanks. These fixes are applied to my local tree (plus a dozen or so fixes for other instances of that Error() problem) and I'll commit it all sometime next week. |
|
Great! |
|
Fixered. |
Date Modified | Username | Field | Change |
---|---|---|---|
2007-08-23 10:06 | jcmdev0 | New Issue | |
2007-08-23 10:06 | jcmdev0 | File Added: error_fix.diff | |
2007-08-23 17:55 | taylor | Note Added: 0008398 | |
2007-08-23 17:55 | taylor | Status | new => assigned |
2007-08-23 17:55 | taylor | Assigned To | => taylor |
2007-08-27 10:05 | jcmdev0 | Note Added: 0008415 | |
2007-10-18 01:25 | taylor | Status | assigned => resolved |
2007-10-18 01:25 | taylor | Fixed in Version | => 3.6.10 |
2007-10-18 01:25 | taylor | Resolution | open => fixed |
2007-10-18 01:25 | taylor | Note Added: 0008572 |