View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002609 | FSSCP | public | 2012-02-20 22:48 | 2012-02-21 15:19 | |
Reporter | Eli2 | Assigned To | CommanderDJ | ||
Priority | high | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | Linux | ||||
Product Version | Antipodes 8 | ||||
Summary | 0002609: Segmentation fault when starting antipodes on linux | ||||
Description | When i try to start antipodes i get a crash after selecting a pilot on startup. This does not seem to happen on windows. | ||||
Additional Information | Thread [1] 15382 [core: 2] (Suspended : Signal : SIGSEGV:Segmentation fault) std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::size() at basic_string.h:711 0x49648c std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::assign() at basic_string.tcc:264 0x495351 std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::assign() at basic_string.h:1.121 0x493f0c std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::operator=() at basic_string.h:550 0x492707 mission_campaign_load() at missioncampaign.cpp:527 0x75a59f mission_load_up_campaign() at missioncampaign.cpp:1.573 0x75d11c game_enter_state() at freespace.cpp:5.953 0x4745c4 gameseq_set_state() at gamesequence.cpp:282 0x860439 game_process_event() at freespace.cpp:5.135 0x47354a gameseq_process_events() at gamesequence.cpp:397 0x86091d game_main() at freespace.cpp:7.114 0x475f82 main() at freespace.cpp:7.248 0x476182 EDIT (CDJ): Here's a stack trace from jg18 on the same issue at the time of the segfault: Program received signal SIGSEGV, Segmentation fault. 0x08089d19 in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::size (this=0x88c7a00) at /usr/include/c++/4.4/bits/basic_string.h:629 629 { return _M_rep()->_M_length; } (gdb) bt #0 0x08089d19 in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::size (this=0x88c7a00) at /usr/include/c++/4.4/bits/basic_string.h:629 0000001 0x080b59de in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::assign (this=0x88c7a00, __s=0x84cf1ea "0", __n=1) at /usr/include/c++/4.4/bits/basic_string.tcc:263 0000002 0x080c03b3 in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::assign (this=0x88c7a00, __s=0x84cf1ea "0") at /usr/include/c++/4.4/bits/basic_string.h:975 0000003 0x080bff10 in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::operator= (this=0x88c7a00, __s=0x84cf1ea "0") at /usr/include/c++/4.4/bits/basic_string.h:519 0000004 0x081e416c in mission_campaign_load (filename=0x8749400 "FreeSpace2.fc2", pl=0x8c24880, load_savefile=1) at mission/missioncampaign.cpp:527 0000005 0x081e6a19 in mission_load_up_campaign (pl=0x8c24880) at mission/missioncampaign.cpp:1578 0000006 0x0805a5e3 in game_enter_state (old_state=37, new_state=1) at freespace2/freespace.cpp:5953 0000007 0x080f37ab in gameseq_set_state (new_state=1, override=0) at gamesequence/gamesequence.cpp:282 0000008 0x0805943e in game_process_event (current_state=37, event=0) at freespace2/freespace.cpp:5135 0000009 0x080f3bc4 in gameseq_process_events () at gamesequence/gamesequence.cpp:397 0000010 0x0805bfcd in game_main (cmdline=0x9af39e0 "") at freespace2/freespace.cpp:7114 #11 0x0805c164 in main (argc=1, argv=0xbffff9c4) at freespace2/freespace.cpp:7248 | ||||
Tags | memset | ||||
|
Attaching a patch to fix this shortly. Credit for this should really go to IssMneur. He identified the problem and tracked down the cause. I just wrote the patch. This was caused by memsets clobbering the pointer that SCP_string used to check its length before assignment. |
|
mantis2609.patch (3,357 bytes)
Index: code/freespace2/freespace.cpp =================================================================== --- code/freespace2/freespace.cpp (revision 8528) +++ code/freespace2/freespace.cpp (working copy) @@ -7347,7 +7347,7 @@ ship_close(); // free any memory that was allocated for the ships hud_free_scrollback_list();// free space allocated to store hud messages in hud scrollback unload_animating_pointer();// frees the frames used for the animating mouse pointer - mission_campaign_close(); // close out the campaign stuff + mission_campaign_clear(); // clear out the campaign stuff message_mission_close(); // clear loaded table data from message.tbl mission_parse_close(); // clear out any extra memory that may be in use by mission parsing multi_voice_close(); // close down multiplayer voice (including freeing buffers, etc) Index: code/mission/missioncampaign.cpp =================================================================== --- code/mission/missioncampaign.cpp (revision 8528) +++ code/mission/missioncampaign.cpp (working copy) @@ -444,7 +444,7 @@ // we must also free any goal stuff that was from a previous campaign // this also frees sexpressions so the next call to init_sexp will be able to reclaim // nodes previously used by another campaign. - mission_campaign_close(); + mission_campaign_clear(); strcpy_s( Campaign.filename, filename ); @@ -456,7 +456,6 @@ read_file_text( filename ); reset_parse(); - memset( &Campaign, 0, sizeof(Campaign) ); // copy filename to campaign structure minus the extension len = strlen(filename) - 4; @@ -715,7 +714,7 @@ */ void mission_campaign_init() { - memset(&Campaign, 0, sizeof(Campaign) ); + mission_campaign_clear(); Campaign_file_missing = 0; } @@ -1206,7 +1205,7 @@ /** * Called when the game closes -- to get rid of memory errors for Bounds checker */ -void mission_campaign_close() +void mission_campaign_clear() { int i; @@ -1267,6 +1266,7 @@ Campaign.missions[i].num_goals = 0; Campaign.missions[i].num_events = 0; Campaign.missions[i].num_variables = 0; // Goober5000 + Campaign.missions[i].main_hall.clear(); } Campaign.num_missions = 0; Index: code/mission/missioncampaign.h =================================================================== --- code/mission/missioncampaign.h (revision 8528) +++ code/mission/missioncampaign.h (working copy) @@ -180,7 +180,7 @@ extern void mission_campaign_mission_over( bool do_next_mission = true ); // frees all memory at game close time -extern void mission_campaign_close( void ); +extern void mission_campaign_clear( void ); // read in a campaign file. Used by Fred. int mission_campaign_load_fred(char *filename, char *name_verify = NULL); Index: code/network/multi_campaign.cpp =================================================================== --- code/network/multi_campaign.cpp (revision 8528) +++ code/network/multi_campaign.cpp (working copy) @@ -713,7 +713,7 @@ case MC_JIP_INITIAL_PACKET: // clear out the names of the missions - mission_campaign_close(); // should free all data structures which need to be freed + mission_campaign_clear(); // should free all data structures which need to be freed // get the number of campaigns and their names. GET_INT(Campaign.num_missions); |
|
Patch has been tested and verified using Linux Mint 10 (Ubuntu 10.10) 32-bit with GCC 4.4.5. |
|
The patch fixes my crash here. |
|
Changing status to code review, as we're really just waiting on this to be reviewed by someone with commit access to Antipodes and committed. |
|
Fix committed to antipodes@8529. |
fs2open: antipodes r8529 2012-02-21 10:20 Ported: N/A Details Diff |
Fix for Mantis 2609: Resolves segmentation fault under linux caused by memsets clobbering the pointer that SCP_string used to check its length before assignment. |
Affected Issues 0002609 |
|
mod - /branches/antipodes/code/network/multi_campaign.cpp | Diff File | ||
mod - /branches/antipodes/code/mission/missioncampaign.h | Diff File | ||
mod - /branches/antipodes/code/mission/missioncampaign.cpp | Diff File | ||
mod - /branches/antipodes/code/freespace2/freespace.cpp | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-02-20 22:48 | Eli2 | New Issue | |
2012-02-20 22:48 | Eli2 | Status | new => assigned |
2012-02-20 22:48 | Eli2 | Assigned To | => CommanderDJ |
2012-02-21 00:41 | CommanderDJ | Additional Information Updated | |
2012-02-21 02:55 | CommanderDJ | Note Added: 0013339 | |
2012-02-21 02:55 | CommanderDJ | File Added: mantis2609.patch | |
2012-02-21 03:05 | jg18 | Note Added: 0013340 | |
2012-02-21 03:13 | Eli2 | Note Added: 0013341 | |
2012-02-21 03:16 | CommanderDJ | Note Added: 0013342 | |
2012-02-21 03:16 | CommanderDJ | Status | assigned => code review |
2012-02-21 03:58 | iss_mneur | Tag Attached: memset | |
2012-02-21 15:19 | Zacam | Changeset attached | => fs2open antipodes r8529 |
2012-02-21 15:19 | Zacam | Note Added: 0013343 | |
2012-02-21 15:19 | Zacam | Status | code review => resolved |
2012-02-21 15:19 | Zacam | Resolution | open => fixed |