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
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Oct 20, 2009 2:31 am   

[3.10a] BUG: Invalid Pointer Operation, issue with editing variable.
 
I've finally managed to reproduce a bug that I've seen a few times. When I first found this bug it corrupted my settings and started putting things outside of the window class in the settings. Here's how to reproduce the bug: Create a blank session, open up the settings, create a variable, enable Use Default, and start continuously editing and saving the variable, using only numbers. This should give you the invalid pointer operation error after a few times. I have not been able to reproduce this with letters or with the Use Default option disabled. Hopefully others will be able to reproduce this as well. Here's the error report:

Code:
date/time         : 2009-10-19, 19:24:29, 406ms
computer name     : STONEWAL-B09690
user name         : Administrator <admin>
registered owner  : Stonewall-64x1
operating system  : Windows XP x64 Service Pack 2 build 3790
system language   : English
system up time    : 8 days 4 hours
program up time   : 29 seconds
processors        : 2x AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
physical memory   : 860/2047 MB (free/total)
free disk space   : (C:) 2.51 GB
display mode      : 1680x1050, 32 bit
process id        : $1a28
allocated memory  : 36.84 MB
executable        : cMUD.exe
exec. date/time   : 2009-07-28 15:46
version           : 3.10.0.1
compiled with     : BCB 2006/07
madExcept version : 3.0h
callstack crc     : $273eff8a, $cac61c92, $cac61c92
exception number  : 1
exception class   : EInvalidPointer
exception message : Invalid pointer operation.

Main ($b74):
00405e01 +016 cMUD.exe   System            38  +0 @LStrClr
0064b8ee +08a cMUD.exe   UTILS            863 +10 IsNumber
00d60fb0 +050 cMUD.exe   PrefDat         7626  +3 VarRec.LoadValRec
00d612d6 +04a cMUD.exe   PrefDat         7674  +5 VarRec.SetValue
00d66a37 +2b3 cMUD.exe   PrefDat         9603 +36 PrefRec.LoadCache
00d64038 +27c cMUD.exe   PrefDat         8829 +33 PrefRec.UpdateFromDB
00d58c99 +135 cMUD.exe   PrefDat         2931 +21 PkgData.AfterPost
008b830b +07b cMUD.exe   DataSetHandler   179  +7 THandlerList.CallHandlers
008b89d0 +004 cMUD.exe   DataSetHandler   255  +0 THandlerList.DoAfterPost
00517981 +015 cMUD.exe   DB                       TDataSet.DoAfterPost
0062e418 +054 cMUD.exe   kbmMemTable    14937 +12 TkbmCustomMemTable.DoAfterPost
00da9f2f +017 cMUD.exe   PkgDM           4477  +1 TPkg.SaveSetting
00c18998 +16c cMUD.exe   PkgMain         5403 +30 TPkgMainF.CheckDupPost
00c0f5a7 +1cb cMUD.exe   PkgMain         1903 +28 TPkgMainF.SaveSetting
00c160bd +061 cMUD.exe   PkgMain         4267 +11 TPkgMainF.DoSave
00c17a08 +000 cMUD.exe   PkgMain         4839  +0 TPkgMainF.SaveChangesExecute
0047b73f +00f cMUD.exe   Classes                  TBasicAction.Execute
004cbcb5 +031 cMUD.exe   ActnList                 TContainedAction.Execute
004cc97c +050 cMUD.exe   ActnList                 TCustomAction.Execute
0047b60b +013 cMUD.exe   Classes                  TBasicActionLink.Execute
006ae4ae +052 cMUD.exe   dxBar          37238  +5 TdxBarItem.DoClick
006ae42b +03b cMUD.exe   dxBar          37226  +4 TdxBarItem.DirectClick
006b26bc +154 cMUD.exe   dxBar          39493 +32 TdxBarItemControl.ControlUnclick
006b579a +056 cMUD.exe   dxBar          41411  +6 TdxBarButtonControl.ControlUnclick
0069b2de +0fe cMUD.exe   dxBar          27162 +24 TCustomdxBarControl.WMLButtonUp
006a00f3 +127 cMUD.exe   dxBar          29823 +38 TdxBarControl.WMLButtonUp
004bb023 +2bb cMUD.exe   Controls                 TControl.WndProc
004bf027 +4fb cMUD.exe   Controls                 TWinControl.WndProc
0069bed7 +2a7 cMUD.exe   dxBar          27516 +60 TCustomdxBarControl.WndProc
006a46ca +002 cMUD.exe   dxBar          32031  +0 TdxBarControl.IsInternal
0069d6df +007 cMUD.exe   dxBar          28313  +1 TCustomdxBarControl.GetEquivalentParentBar
0069c942 +01a cMUD.exe   dxBar          27853  +6 TCustomdxBarControl.CanProcessMouseMessage
004be750 +02c cMUD.exe   Controls                 TWinControl.MainWndProc
0047c400 +014 cMUD.exe   Classes                  StdWndProc
7d94ab81 +00a USER32.dll                          DispatchMessageA
004a96fc +0fc cMUD.exe   Forms                    TApplication.ProcessMessage
004a9736 +00a cMUD.exe   Forms                    TApplication.HandleMessage
004a9a2b +0b3 cMUD.exe   Forms                    TApplication.Run
00e0015c +088 cMUD.exe   CMUD             352 +20 initialization
Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Tue Oct 20, 2009 3:36 am   
 
I can reproduce this and it appears to crash at the same spot as General's.

Code:
date/time         : 2009-10-19, 20:32:02, 620ms
computer name     : <stripped>
user name         : <stripped>
registered owner  : <stripped>
operating system  : Windows Vista x64 Service Pack 2, v.286 build 6002
system language   : English
system up time    : 9 days 4 hours
program up time   : 12 hours 47 minutes
processors        : 2x Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz
physical memory   : 1804/4096MB (free/total)
free disk space   : (C:) 132.58 GB
display mode      : 1920x1200, 32 bit
process id        : $1a0c
allocated memory  : 120.69 MB
executable        : cMUDPro.exe
exec. date/time   : 2009-07-28 15:47
version           : 3.10.0.1
compiled with     : BCB 2006/07
madExcept version : 3.0h
contact name      : <stripped>
contact email     : <stripped>
callstack crc     : $657ad605, $03085919, $03085919
exception number  : 1
exception class   : EInvalidPointer
exception message : Invalid pointer operation.

Main ($169c):
00405f09 +021 cMUDPro.exe  System           281  +0 @LStrClr
0065130a +08a cMUDPro.exe  UTILS            863 +10 IsNumber
00ec7f3c +050 cMUDPro.exe  PrefDat         7626  +3 VarRec.LoadValRec
00ec8262 +04a cMUDPro.exe  PrefDat         7674  +5 VarRec.SetValue
00ecd9c3 +2b3 cMUDPro.exe  PrefDat         9603 +36 PrefRec.LoadCache
00ecafc4 +27c cMUDPro.exe  PrefDat         8829 +33 PrefRec.UpdateFromDB
00ebfc25 +135 cMUDPro.exe  PrefDat         2931 +21 PkgData.AfterPost
008bdd7b +07b cMUDPro.exe  DataSetHandler   179  +7 THandlerList.CallHandlers
008be440 +004 cMUDPro.exe  DataSetHandler   255  +0 THandlerList.DoAfterPost
0051c135 +015 cMUDPro.exe  DB                       TDataSet.DoAfterPost
00633c84 +054 cMUDPro.exe  kbmMemTable    14937 +12 TkbmCustomMemTable.DoAfterPost
00f10eb7 +017 cMUDPro.exe  PkgDM           4477  +1 TPkg.SaveSetting
00d6e344 +16c cMUDPro.exe  PkgMain         5403 +30 TPkgMainF.CheckDupPost
00d64f53 +1cb cMUDPro.exe  PkgMain         1903 +28 TPkgMainF.SaveSetting
00d6ba69 +061 cMUDPro.exe  PkgMain         4267 +11 TPkgMainF.DoSave
00d6d3b4 +000 cMUDPro.exe  PkgMain         4839  +0 TPkgMainF.SaveChangesExecute
0047bb13 +00f cMUDPro.exe  Classes                  TBasicAction.Execute
004d038d +031 cMUDPro.exe  ActnList                 TContainedAction.Execute
004d1054 +050 cMUDPro.exe  ActnList                 TCustomAction.Execute
0047b9df +013 cMUDPro.exe  Classes                  TBasicActionLink.Execute
006b3f1e +052 cMUDPro.exe  dxBar          37238  +5 TdxBarItem.DoClick
006b3e9b +03b cMUDPro.exe  dxBar          37226  +4 TdxBarItem.DirectClick
006b812c +154 cMUDPro.exe  dxBar          39493 +32 TdxBarItemControl.ControlUnclick
006bb20a +056 cMUDPro.exe  dxBar          41411  +6 TdxBarButtonControl.ControlUnclick
006a0d4e +0fe cMUDPro.exe  dxBar          27162 +24 TCustomdxBarControl.WMLButtonUp
006a5b63 +127 cMUDPro.exe  dxBar          29823 +38 TdxBarControl.WMLButtonUp
004bf5eb +2bb cMUDPro.exe  Controls                 TControl.WndProc
004c35ef +4fb cMUDPro.exe  Controls                 TWinControl.WndProc
006a1947 +2a7 cMUDPro.exe  dxBar          27516 +60 TCustomdxBarControl.WndProc
006aa13a +002 cMUDPro.exe  dxBar          32031  +0 TdxBarControl.IsInternal
006a314f +007 cMUDPro.exe  dxBar          28313  +1 TCustomdxBarControl.GetEquivalentParentBar
006a23b2 +01a cMUDPro.exe  dxBar          27853  +6 TCustomdxBarControl.CanProcessMouseMessage
004c2d18 +02c cMUDPro.exe  Controls                 TWinControl.MainWndProc
0047c7d4 +014 cMUDPro.exe  Classes                  StdWndProc
766190de +00a USER32.dll                            DispatchMessageA
004adcc4 +0fc cMUDPro.exe  Forms                    TApplication.ProcessMessage
004adcfe +00a cMUDPro.exe  Forms                    TApplication.HandleMessage
004adff3 +0b3 cMUDPro.exe  Forms                    TApplication.Run
00f67f28 +088 cMUDPro.exe  cMUDPro          362 +20 initialization
75d3ec1b +00c kernel32.dll                          BaseThreadInitThunk
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Oct 20, 2009 7:27 am   
 
I get this behavior when I'm editing only the values of a database variable as well. This seems like a rather big bug as it can cause settings to become corrupted. I just hope this can be included in the next version.
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Tue Oct 20, 2009 12:27 pm   
 
neither setting a default value, or changing the variable type seem to help, it does seem to need to be a number thou.
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Oct 20, 2009 4:28 pm   
 
Good catch! I was able to reproduce this with the procedure that you gave. Definitely a very odd bug, but hopefully I can track it down using this procedure. Thanks for the post.
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Oct 20, 2009 5:31 pm   
 
I think I found this one, but it was very obscure. In fact, I think it might be some sort of string-reference memory bug deep within Delphi.

For variables with "Use Default" set, CMUD was doing the following to avoid having the new value saved in the database:
Code:
Value := fValue

where fValue is the internal string value stored for the variable. This just essentially just causes Delphi to call the "SetValue" method for the object. And in the SetValue it does something like this:
Code:
procedure VarRec.SetValue( const S: String);
begin
  if (S <> fValue) then // save new value to database
  LoadValRec( S, Kind);
end;

So by doing "Value := fValue", that was ensuring that "S = fValue" so the "save new value to database wasn't called".

OK, that was fine. Then the "LoadValRec" routine was responsible for loading the internal cache. The cache stored different data types to speed up things later. So it has code something like this:
Code:
procedure VarRec.LoadValRec( const S: String; Kind: Integer);
begin
  if (Kind = kindAuto) then begin
    if IsNumber(S) then ValNode.AsInt := StrToInt(S)
    else if IsFloat(S) then ValNode.AsFloat := StrToFloat(S)
    else ValNode.AsString := S;
    end;
  ...
end;

The crash was coming at the end of the "IsNumber" routine when Delphi tries to free up the string if the reference count is zero. That is the crash in the @LStrClr routine as shown in the above crash dump.

So somehow the reference count on the passed string (which is traced back to the fValue string field) was getting messed up.

I have no idea what the underlying bug in this is, or if it's a bug in Delphi's string handling. But I changed the first line of code to this:
Code:
S := fValue;
SetValue(S);

and that fixed the crash. Basically I am setting another reference to the fValue string and passing that down the line. My guess is that the simple:
Code:
Value := fValue

line from before was not properly adding a reference count to fValue or something.

Anyway, it's a bit of a kludge, but it seems to work. It would have been nice if I could really track down the underlying cause of this weirdness to avoid it in the future, but I just don't have that kind of time right now and debugging the low-level string reference counting in Delphi is very time intensive.
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Oct 20, 2009 7:43 pm   
 
Good stuff Zugg!

*Tells more people to buy Cmud*
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