Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Wed Apr 09, 2008 3:07 pm   

[2.22] Updating buttons through events causes crash
 
I first noticed this issue in 2.18 and it's still in 2.22. I finally took some time to reproduce it in the untitled session, so here's some more details.

Code:
#ALIAS trythis {
#RAISE OnTryThis
}
#BUTTON 0 {Blah} {#SAY "Button"} {} {} {} {} {} {Size} {140} {23} {} {} {} {14} {} {} {} "" {Explore} {} {mybutton}
#EVENT OnTryThis {
#CALL %btncol("mybutton", red, white)
}


The first time I use the "trythis" alias, I get a dialog that says "System error 5. Access denied." (or something along those lines) with "trythis" in the edit box part. Wait a second or two (may need to try the alias again, though not always) and CMUD crashes:
Code:
date/time         : 2008-04-09, 10:53:24, 755ms
operating system  : Windows XP Service Pack 2 build 2600
system language   : English
system up time    : 38 minutes 39 seconds
program up time   : 3 minutes 7 seconds
processors        : 2x Intel(R) Xeon(TM) CPU 3.20GHz
physical memory   : 1259/2046 MB (free/total)
free disk space   : (C:) 190.62 GB
display mode      : 1600x1200, 32 bit
process id        : $a90
allocated memory  : 22.00 MB
executable        : cMUDPro.exe
exec. date/time   : 2008-04-04 19:27
version           : 2.22.0.0
compiled with     : BCB 2006
madExcept version : 3.0e
callstack crc     : $def96eb1, $cfacfeb1, $cfacfeb1
exception number  : 1
exception class   : EAccessViolation
exception message : Access violation at address 7C918FEA in module 'ntdll.dll'. Write of address 00000010.

Main ($1298):
7c918fea +05b ntdll.dll                             RtlpWaitForCriticalSection
7c901046 +041 ntdll.dll                             RtlEnterCriticalSection
00484b36 +01e cMUDPro.exe  Graphics                 TCanvas.Lock
004c35b7 +013 cMUDPro.exe  Controls                 TCustomControl.PaintWindow
004bea21 +055 cMUDPro.exe  Controls                 TWinControl.PaintHandler
004bf194 +048 cMUDPro.exe  Controls                 TWinControl.WMPaint
004c3594 +010 cMUDPro.exe  Controls                 TCustomControl.WMPaint
004ba867 +2bb cMUDPro.exe  Controls                 TControl.WndProc
004be86b +4fb cMUDPro.exe  Controls                 TWinControl.WndProc
004bdf94 +02c cMUDPro.exe  Controls                 TWinControl.MainWndProc
0047bc88 +014 cMUDPro.exe  Classes                  StdWndProc
7c90eae0 +010 ntdll.dll                             KiUserCallbackDispatcher
7e41d825 +02c USER32.dll                            UpdateWindow
004c12e1 +015 cMUDPro.exe  Controls                 TWinControl.Update
004c12f9 +011 cMUDPro.exe  Controls                 TWinControl.Repaint
00723c59 +015 cMUDPro.exe  explbtn        1661   +4 TExplorerButton.SetUnselectedFontColor
00e559d7 +44b cMUDPro.exe  PrefDat        8677  +74 ButtonRec.Invalidate
00d6b51b +93f cMUDPro.exe  PARENT         4521 +194 TParentForm.UpdateButtons
00d688cb +06f cMUDPro.exe  PARENT         3329  +15 TParentForm.DoRefreshSetting
00d68922 +032 cMUDPro.exe  PARENT         3343   +2 TParentForm.wmRefreshSetting
004ba867 +2bb cMUDPro.exe  Controls                 TControl.WndProc
004be86b +4fb cMUDPro.exe  Controls                 TWinControl.WndProc
004a0dcb +553 cMUDPro.exe  Forms                    TCustomForm.WndProc
004ba867 +2bb cMUDPro.exe  Controls                 TControl.WndProc
00d0f61c +020 cMUDPro.exe  DXSounds       2128   +9 TCustomDXSound.FormWndProc
00d0cdc0 +00c cMUDPro.exe  DXClass         635   +1 TControlSubClass.WndProc
004bdf94 +02c cMUDPro.exe  Controls                 TWinControl.MainWndProc
0047bc88 +014 cMUDPro.exe  Classes                  StdWndProc
7e41f658 +016 USER32.dll                            CallWindowProcA
006d2097 +0a7 cMUDPro.exe  aqDockingUtils 1728   +7 CallDefWndProc
006d2185 +0dd cMUDPro.exe  aqDockingUtils 1776  +41 TaqWindowEventFilter.WndProc
0047bc88 +014 cMUDPro.exe  Classes                  StdWndProc
7e4196c2 +00a USER32.dll                            DispatchMessageA
004a8f40 +0fc cMUDPro.exe  Forms                    TApplication.ProcessMessage
004a8f7a +00a cMUDPro.exe  Forms                    TApplication.HandleMessage
004a926f +0b3 cMUDPro.exe  Forms                    TApplication.Run
00eeb08c +088 cMUDPro.exe  cMUDPro         352  +20 initialization
7c91312f +069 ntdll.dll                             RtlUnicodeStringToAnsiString
7c812b94 +0b6 kernel32.dll                          GetVersionExA


I'd really love to see this issue resolved in 2.23 because it's making it really difficult (next to impossible) to keep my buttons in sync with my settings when I don't directly click on the button to change the value...

Note: this is the most pared down I could get the code for this bug other than to simply raise the event from the command-line. My own code is quite a bit more complicated than this. Smile

Edit: I should also mention that this is probably directly related to the issue of events not running in the proper context, but this is a good, specific example of the issue.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 23, 2008 7:40 pm   
 
Added to bug list.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Apr 25, 2008 9:04 pm   
 
I've got this fixed for 2.23. It was a combination bug. The immediate problem was that CMUD was trying to update the color of the button while running in a background thread. And since you are not allowed to access user interface components in Windows from a thread, this was causing a crash.

So first I fixed the button Update routine so that it doesn't run if called in a background thread. It sends a windows message so that the main thread can update the button.

But then I asked myself why it was doing this from a background thread in the first place? The %btncol function is marked as not thread-safe, and it is supposed to be executed in the main thread anyway. So why was it being executed from a background thread?

Turns out there was a nasty problem when using the #RAISE command to execute an event. The event was sharing the existing thread (the command line thread in this case), but wasn't passing that thread to the execution routines. So the execution routines thought they were not running in a thread and was just calling the button update routine directly.

So this bug could cause a number of crash problems when raising events. And all of those problems should be fixed in 2.23 now.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sat Apr 26, 2008 3:18 am   
 
Sweeet! This will make my life more pleasant, I think.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net