Source Code Project Mantis - FSSCP
View Issue Details
0001680FSSCPFREDpublic2008-05-01 04:252008-10-28 14:15
ReporterFUBAR-BDHR 
Assigned Tokarajorma 
PriorityhighSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.6.9 
Target VersionFixed in Version3.6.10 
Summary0001680: Disbanding wing results in "Assert: (wing < MAX_WINGS) && Wings[wing].wave_count"
DescriptionAttempting to disbanding a wing that is referenced in an event I get the usual yes no cancel window. I am going to delete the event so I said yes. Second window pops up for the same event and again I say yes. Then I receive a window with a $ and 2 squares. Clicking OK (only option) gave me a message something like wave threshold to high setting to -1. That results in an infinite loop of that same error over and over.

Tried running debug build and instead of the $ and 2 box message I received one with a bunch of exclamation points followed by this:

Assert: (wing < MAX_WINGS) && Wings[wing].wave_count
File: d:\c++\freespace\fs2_open 3.6.9 - btrl\code\fred2\shipeditordlg.cpp
Line: 1419
[This filename points to the location of a file on the computer that built this executable]

Call stack:
------------------------------------------------------------------
    fred2_open_3_6_9_debug_INF.exe 00458bce()
    fred2_open_3_6_9_debug_INF.exe 0043fd2a()
    fred2_open_3_6_9_debug_INF.exe 0094f9ed()
    fred2_open_3_6_9_debug_INF.exe 0094f184()
    fred2_open_3_6_9_debug_INF.exe 0094cd29()
    fred2_open_3_6_9_debug_INF.exe 0094d1c5()
    USER32.dll 7e418734()
    USER32.dll 7e418816()
    USER32.dll 7e41c63f()
    USER32.dll 7e41c665()
    OPENGL32.dll 5ed2699b()
    USER32.dll 7e418734()
    USER32.dll 7e418816()
    USER32.dll 7e41b4c0()
    USER32.dll 7e41b50c()
------------------------------------------------------------------
Additional InformationTBP build of FRED 3.6.9 dated 3/30/08. To reproduce the error load the attached mission, open the wing editor, select maint bot wing 4 and hit disband.
TagsNo tags attached.
Attached Files? FUBAR_M02.fs2 (36,476) 2008-05-01 04:25
http://scp.indiegames.us/mantis/file_download.php?file_id=1026&type=bug
log fs2_open.log (81,272) 2008-05-01 04:25
http://scp.indiegames.us/mantis/file_download.php?file_id=1027&type=bug
? Disband Me.fs2 (4,036) 2008-10-24 18:04
http://scp.indiegames.us/mantis/file_download.php?file_id=1130&type=bug
diff 1680.diff (3,443) 2008-10-25 06:24
http://scp.indiegames.us/mantis/file_download.php?file_id=1131&type=bug

Notes
(0009334)
karajorma   
2008-05-15 16:07   
Does this only occur if you disband the wing with the ships editor open?
(0009337)
FUBAR-BDHR   
2008-05-15 19:55   
When I was trying it I did not have the ships editor open just the wing editor. I may have had it opened the first time I crashed but the next time and the time I ran debug I did not. Just opened the mission, went to the wing editor and started disbanding the wings. I can try it with the ship editor open lather and see what happens.
(0009882)
chief1983   
2008-10-09 01:01   
Definitely happens in the most recent 4670 revision, regardless of VS2008 or VC6 as a compiler. Crashes the same in both. Gonna bump priority and confirm. Kara, I'm guessing you'll be taking another look at this, but if you think it's not worth fixing in the immediate future then feel free to bump priority back down.
(0010063)
chief1983   
2008-10-20 02:46   
Reading my last note, I must have meant 4870 and not 4670. Had to be a typo.
(0010117)
karajorma   
2008-10-24 18:03   
I'll be damned if I can figure out what the hell is going on here. I managed to chase the error down to somewhere in MessageBox()

Somewhere in afxcomctl32 this function is being called.

 AFX_ISOLATIONAWARE_STATICLINK_FUNC(int ,MessageBoxA,(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType),(hWnd,lpText,lpCaption,uType),0)

The data going in doesn't look particularly dodgy so I have no idea what is causing it at all.

What's really strange is that error is coming from sexp_reference_handler() from the first of these two lines

r = Fred_main_wnd->MessageBox(msg, "Warning", MB_YESNOCANCEL | MB_ICONEXCLAMATION);
if (r == IDNO)

Yet if I breakpoint both lines I can still get the code to give the "Disbanding wing results in "Assert: (wing < MAX_WINGS) && Wings[wing].wave_count"" error. Without hitting the second breakpoint! I have no explanation for this. After the weird error message the program is somehow leaving the Messagebox() code and somehow continuing to execute FRED2 code without passing any intervening code.

Anyway I'm attaching a much simpler mission that displays the exact same behaviour.
(0010121)
taylor   
2008-10-25 06:33   
The attached diff seems to fix it, though it really needs more of a test than what I put it through before it gets committed.

The first problem is that dialog that just gives garbage characters. That is a simple one to deal with. When it gets to one particular function that bypasses errors, the bypass skips the creation of the error message, but still tries to show the popup. Simply putting the popup in the same bypass check makes sure that it will skip both and then avoid giving you a popup with garbage text (or possibly even crashing).

The second problem is Volition, who wrote some crappy code. ;) The delete wing and disband wing buttons actually did the same thing. The double "referenced an event" message is simply because the function that generates it got called twice, once in the disband function and once in the delete function. This issue not only caused the weird error messages, and the Assert() call getting called when it never should have gotten that far, but also made disbanding a wing also delete the ships that were in said wing. The fix for this is to make the disband function actually do the wing cleanup like the delete wing function does. The trick is merely passing a 0 to remove_ship_from_wing() so that it avoids calling the delete wing function once the wing would be empty. Now you get the wing removed, but the ships remain intact (other than being renamed).
(0010133)
taylor   
2008-10-28 14:15   
No objections. No complaints. So...


Fixered.

Issue History
2008-05-01 04:25FUBAR-BDHRNew Issue
2008-05-01 04:25FUBAR-BDHRFile Added: FUBAR_M02.fs2
2008-05-01 04:25FUBAR-BDHRFile Added: fs2_open.log
2008-05-15 16:07karajormaNote Added: 0009334
2008-05-15 19:55FUBAR-BDHRNote Added: 0009337
2008-10-09 01:01chief1983Note Added: 0009882
2008-10-09 01:01chief1983Prioritynormal => high
2008-10-09 01:01chief1983Statusnew => confirmed
2008-10-19 13:29karajormaStatusconfirmed => assigned
2008-10-19 13:29karajormaAssigned To => karajorma
2008-10-20 02:46chief1983Note Added: 0010063
2008-10-24 18:03karajormaNote Added: 0010117
2008-10-24 18:04karajormaFile Added: Disband Me.fs2
2008-10-25 06:24taylorFile Added: 1680.diff
2008-10-25 06:33taylorNote Added: 0010121
2008-10-28 14:15taylorStatusassigned => resolved
2008-10-28 14:15taylorFixed in Version => 3.6.10
2008-10-28 14:15taylorResolutionopen => fixed
2008-10-28 14:15taylorNote Added: 0010133