Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in built-in debugger after restoring from minimised #820

Closed
tomcw opened this issue Aug 6, 2020 · 4 comments
Closed

Crash in built-in debugger after restoring from minimised #820

tomcw opened this issue Aug 6, 2020 · 4 comments

Comments

@tomcw
Copy link
Contributor

tomcw commented Aug 6, 2020

Using a debug build from HEAD of master (so ahead of 1.29.13.0(rel)).

Repro:

  • Run SST, doing a drive speed check on drive-2 (blankwoz.woz)
  • Minimize AppleWin
  • (wait 1 minute?)
  • Restore AppleWin (black screen, no buttons, no toolbar)
  • F7 (in an attempt to force a redraw)
  • Crash...
>	AppleWin.exe!FillBackground(long left=0x00000000, long top=0x00000000, long right=0x00000161, long bottom=0x00000008)  Line 909 + 0x12 bytes	C++
 	AppleWin.exe!PrintText(const char * pText=0x0018f4a4, tagRECT & rRect={...})  Line 885 + 0x20 bytes	C++
 	AppleWin.exe!PrintTextCursorX(const char * pText=0x0018f4a4, tagRECT & rRect={...})  Line 934 + 0xd bytes	C++
 	AppleWin.exe!DrawDisassemblyLine(int iLine=0x00000000, const unsigned short nBaseAddress=0xb90f)  Line 2115 + 0x13 bytes	C++
 	AppleWin.exe!DrawSubWindow_Code(int iWindow=0x00000002)  Line 4278 + 0xe bytes	C++
 	AppleWin.exe!DrawWindow_Code(int bUpdate=0xffffffff)  Line 4057 + 0xb bytes	C++
 	AppleWin.exe!UpdateDisplay(int bUpdate=0xffffffff)  Line 4201 + 0x9 bytes	C++
 	AppleWin.exe!DebugBegin()  Line 8632 + 0x7 bytes	C++
 	AppleWin.exe!ProcessButtonClick(int button=0x00000006, bool bFromButtonUI=true)  Line 2134	C++
 	AppleWin.exe!FrameWndProc(HWND__ * window=0x000104ae, unsigned int message=0x00000101, unsigned int wparam=0x00000076, long lparam=0xc0410001)  Line 1505 + 0xe bytes	C++
 	user32.dll!7728630a() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]	
 	user32.dll!77286d4a() 	
 	user32.dll!77286cf9() 	
 	user32.dll!772877d7() 	
 	user32.dll!77287bda() 	
 	AppleWin.exe!EnterMessageLoop()  Line 515 + 0xa bytes	C++
 	AppleWin.exe!WinMain(HINSTANCE__ * passinstance=0x00400000, HINSTANCE__ * __formal=0x00000000, char * lpCmdLine=0x002c684d, HINSTANCE__ * __formal=0x00000000)  Line 1400	C++
 	AppleWin.exe!__tmainCRTStartup()  Line 263 + 0x2c bytes	C
 	AppleWin.exe!WinMainCRTStartup()  Line 182	C
 	kernel32.dll!7512343d() 	
 	ntdll.dll!77989812() 	
 	ntdll.dll!779897e5() 	

Crash reason:
g_pDebuggerMemFramebits == NULL

Probably crash introduced at "Improved debugger video performance (#800)": af9568c


Reproduced the black screen with 1.29.13.0(rel), but no crash with F7.

  • couldn't get the buttons / screen to redraw though.
@tomcw tomcw added this to the 1.29.14 milestone Aug 16, 2020
@tomcw
Copy link
Contributor Author

tomcw commented Aug 16, 2020

NB. Tried to repro (but failed) by doing...

  • Boot to AppleSoft, set full-speed, and minimise (waited 1 min)
  • Boot to AppleSoft, read C0E9 (motor on), and minimise (waited 2 mins)

@tomcw
Copy link
Contributor Author

tomcw commented Aug 16, 2020

At the point of the crash, AppleWin's GDI Objects = 10,000 (from Task Manager).

Normally, just booting a disk, and F7, then GDI Objects = 66 (and repeatedly pressing F7 to enter/exit debugger, doesn't increase/leak GDI Objects).

But when running SST's Check Drive Speed, and minimising, then Task Manager shows GDI Objects increasing by ~1000/second! Unminimising (eg. when GDI Objects = 4775) doesn't release these GDI objects.

As a check, restarting AppleWin, then boot to AppleSoft + read C0E9 (or running at full-speed) + minimising doesn't cause GDI Objects to increase.

@tomcw
Copy link
Contributor Author

tomcw commented Aug 16, 2020

A binary-chop shows this leak was introduced in 1.25.0.0 (it doesn't occur in 1.24.0.0).
GDIView.exe shows that it's DC objects that are leaking.

@tomcw
Copy link
Contributor Author

tomcw commented Aug 16, 2020

The DC leak was occurring in this function: FrameDrawDiskStatus(), specifically on this line:

	HDC  dc     = (passdc ? passdc : GetDC(g_hFrameWindow));

I don't understand why it leaks handles only when the app window is minimised.
On this MS doc page for GetDC, it says:

After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released.

So maybe when minimised, the DC is common; but when not minimised it's a class/private DC?

Anyway, this is fixed, so closing.

@tomcw tomcw closed this as completed Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant