Author Topic: [closed] Corrupt memory when loading room (v3.4.0.16)  (Read 232 times)  Share 

arj0n

  • Mittens Vassal
  • why do meteors always land in craters?
  • arj0n worked on a game that was nominated for an AGS Award!
AGS version: v3.4.0.16
Action: I (try to) edit room 39, or compile the project
Problem: an Unhandled Error/ System.AccessViolationException message is shown.
(after restarting the editor and trying to edit the room or compile the project gives the same problem)
Note: the project was made in an older (probably 3.3.x) version of AGS.

When trying to edit room 39:
Error MSG 1:
Code: Adventure Game Studio
  1. Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  2. Version: AGS 3.4.0.16
  3.  
  4. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  5.    at load_room_file(SByte* )
  6.    at load_crm_file(UnloadedRoom roomToLoad)
  7.    at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
  8.    at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
  9.    at AGS.Editor.Components.RoomsComponent.LoadDifferentRoom(UnloadedRoom newRoom)
  10.    at AGS.Editor.Components.RoomsComponent.LoadRoom(String controlID)
  11.    at AGS.Editor.Components.RoomsComponent.ItemCommandClick(String controlID)
  12.    at AGS.Editor.Components.BaseComponentWithFolders`2.CommandClick(String controlID)
  13.    at AGS.Editor.ProjectTree.ProcessClickOnNode(String nodeID, MouseButtons button)
  14.    at AGS.Editor.ProjectTree.projectTree_NodeMouseDoubleClick(Object sender, TreeNodeMouseClickEventArgs e)
  15.    at System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e)
  16.    at System.Windows.Forms.TreeView.WndProc(Message& m)
  17.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  18.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  19.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  20.  

Error MSG 2:
Code: Adventure Game Studio
  1. ---------------------------
  2. Adventure Game Studio
  3. ---------------------------
  4. A serious error occurred and the AGS Editor may now be in an unstable state. You are STRONGLY ADVISED to shut down the editor and restart it. Before saving your work, make a backup copy of your game folder in case any data has been corrupted.
  5.  
  6. Error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  7.  
  8.    at load_room_file(SByte* )
  9.    at load_crm_file(UnloadedRoom roomToLoad)
  10.    at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
  11.    at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
  12.    at AGS.Editor.Components.RoomsComponent.LoadDifferentRoom(UnloadedRoom newRoom)
  13.    at AGS.Editor.Components.RoomsComponent.LoadRoom(String controlID)
  14.    at AGS.Editor.Components.RoomsComponent.ItemCommandClick(String controlID)
  15.    at AGS.Editor.Components.BaseComponentWithFolders`2.CommandClick(String controlID)
  16.    at AGS.Editor.ProjectTree.ProcessClickOnNode(String nodeID, MouseButtons button)
  17.    at AGS.Editor.ProjectTree.projectTree_NodeMouseDoubleClick(Object sender, TreeNodeMouseClickEventArgs e)
  18.    at System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e)
  19.    at System.Windows.Forms.TreeView.WndProc(Message& m)
  20.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  21.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  22.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  23. ---------------------------
  24. OK  
  25. ---------------------------
  26.  

When trying to compile the project:
Error MSG 1:
Code: Adventure Game Studio
  1. Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  2. Version: AGS 3.4.0.16
  3.  
  4. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  5.    at load_room_file(SByte* )
  6.    at load_crm_file(UnloadedRoom roomToLoad)
  7.    at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
  8.    at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
  9.    at AGS.Editor.Components.RoomsComponent.RecompileAnyRoomsWhereTheScriptHasChanged(CompileMessages errors, Boolean rebuildAll)
  10.    at AGS.Editor.Components.RoomsComponent.AGSEditor_PreCompileGame(PreCompileGameEventArgs evArgs)
  11.    at AGS.Editor.AGSEditor.PreCompileGameHandler.Invoke(PreCompileGameEventArgs evArgs)
  12.    at AGS.Editor.AGSEditor.CompileGame(Boolean forceRebuild, Boolean createMiniExeForDebug)
  13.    at AGS.Editor.Components.BuildCommandsComponent.CompileGame(Boolean forceRebuild)
  14.    at AGS.Editor.Components.BuildCommandsComponent.CommandClick(String controlID)
  15.    at AGS.Editor.GUIController._mainForm_OnMenuClick(String menuItemID)
  16.    at AGS.Editor.MainMenuManager.MenuEventHandler(Object sender, EventArgs e)
  17.    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
  18.    at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
  19.    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
  20.    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
  21.    at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
  22.    at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
  23.    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
  24.    at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
  25.    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  26.    at System.Windows.Forms.Control.WndProc(Message& m)
  27.    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
  28.    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
  29.    at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
  30.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  31.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  32.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  33.  

Error MSG 2:
Code: Adventure Game Studio
  1. ---------------------------
  2. Adventure Game Studio
  3. ---------------------------
  4. A serious error occurred and the AGS Editor may now be in an unstable state. You are STRONGLY ADVISED to shut down the editor and restart it. Before saving your work, make a backup copy of your game folder in case any data has been corrupted.
  5.  
  6. Error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  7.  
  8.    at load_room_file(SByte* )
  9.    at load_crm_file(UnloadedRoom roomToLoad)
  10.    at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
  11.    at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
  12.    at AGS.Editor.Components.RoomsComponent.RecompileAnyRoomsWhereTheScriptHasChanged(CompileMessages errors, Boolean rebuildAll)
  13.    at AGS.Editor.Components.RoomsComponent.AGSEditor_PreCompileGame(PreCompileGameEventArgs evArgs)
  14.    at AGS.Editor.AGSEditor.PreCompileGameHandler.Invoke(PreCompileGameEventArgs evArgs)
  15.    at AGS.Editor.AGSEditor.CompileGame(Boolean forceRebuild, Boolean createMiniExeForDebug)
  16.    at AGS.Editor.Components.BuildCommandsComponent.CompileGame(Boolean forceRebuild)
  17.    at AGS.Editor.Components.BuildCommandsComponent.CommandClick(String controlID)
  18.    at AGS.Editor.GUIController._mainForm_OnMenuClick(String menuItemID)
  19.    at AGS.Editor.MainMenuManager.MenuEventHandler(Object sender, EventArgs e)
  20.    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
  21.    at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
  22.    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
  23.    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
  24.    at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
  25.    at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
  26.    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
  27.    at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
  28.    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  29.    at System.Windows.Forms.Control.WndProc(Message& m)
  30.    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
  31.    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
  32.    at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
  33.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  34.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  35.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  36. ---------------------------
  37. OK  
  38. ---------------------------
  39.  
« Last Edit: 06 Jun 2017, 20:33 by arj0n »

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
This happens for years and no one found what causes this yet.
Maybe the room file was broken at some point.

If you have a backup that works in previous version, it may be used to analyse the problem.
« Last Edit: 03 Jun 2017, 18:54 by Crimson Wizard »

arj0n

  • Mittens Vassal
  • why do meteors always land in craters?
  • arj0n worked on a game that was nominated for an AGS Award!
Re: Corrupt memory when loading room (v3.4.0.16)
« Reply #2 on: 03 Jun 2017, 19:52 »
I've uploaded this version plus 2 backups which were made in (most probably) v3.3.4.
As I prefer not to share this project publicly, can I PM you or someone the ftp-url?

EDIT:
I also used the [Send Error Report] option this time for both situations (report 1 = edit room 93, report 2 is compiling project), maybe it provides some extra info.
« Last Edit: 03 Jun 2017, 19:59 by arj0n »

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Corrupt memory when loading room (v3.4.0.16)
« Reply #3 on: 03 Jun 2017, 20:28 »
I've uploaded this version plus 2 backups which were made in (most probably) v3.3.4.
As I prefer not to share this project publicly, can I PM you or someone the ftp-url?

Yes, although I cannot say when I will have time to look into this, may not happen fast.

BTW, I think you may need to upload only one room file (CRM + ASC), because its possible to import rooms into dummy projects to test them.
(Not sure if the error will be persisting though)

I also used the [Send Error Report] option this time for both situations (report 1 = edit room 93, report 2 is compiling project), maybe it provides some extra info.
This is actually same error in both cases, room is loaded before recompiling scripts I think.
« Last Edit: 03 Jun 2017, 20:29 by Crimson Wizard »

arj0n

  • Mittens Vassal
  • why do meteors always land in craters?
  • arj0n worked on a game that was nominated for an AGS Award!
Re: Corrupt memory when loading room (v3.4.0.16)
« Reply #4 on: 03 Jun 2017, 21:10 »
I've sent you a pm.

As I prefer not to share this project publicly, can I PM you or someone the ftp-url?
Yes, although I cannot say when I will have time to look into this, may not happen fast.
Not a problem at all.
I can always try to import the room from the older backup and otherwise create the room again.
Just hope someone can find out what is wrong with this specific room... :)

BTW, I think you may need to upload only one room file (CRM + ASC), because its possible to import rooms into dummy projects to test them.
(Not sure if the error will be persisting though)
I've also included a small zip with only both room files from both backups.

I also used the [Send Error Report] option this time for both situations (report 1 = edit room 93, report 2 is compiling project), maybe it provides some extra info.
This is actually same error in both cases, room is loaded before recompiling scripts I think.
Ah, you're right :-D


Thanx!

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Corrupt memory when loading room (v3.4.0.16)
« Reply #5 on: 06 Jun 2017, 19:50 »
I could not find much except that room file is corrupted.

Importing old room from backup, or even upgrading whole old project to 3.4.0 / 3.4.1 makes it work. Which suggests that it got corrupted at some point after you upgraded to 3.4.0 and did some work to it.

The only thing I could improve at the moment is that I actually found why the program memory exception occured, and instead making it detect a wrong data error and stop loading before it does any more damage to program. So, it will still report about error, but at least that should be relatively safer now.


As for why the room file could get corrupted. When room is saved, it is saved chunk by chunk, and everytime when it's done writing next part it seeks back in file and writes that chunk's size. In this corrupted room the first chunk had size = 0 (which is not true). The data itself seems okay: I checked the variables it loads last, and they look pretty much in the sensible range (and match the working room variant).

So, it wrote room data properly, but then failed to seek back in file and write data size in its place.

TBH I cannot imagine any particular cause right now, except for a glitch in the filesystem that returned zero file length... if that may even happen. Unless you created over 2GB room file somehow, which I doubt is possible.

Maybe if you could remember what happened just before room became corrupt.
« Last Edit: 06 Jun 2017, 20:23 by Crimson Wizard »

arj0n

  • Mittens Vassal
  • why do meteors always land in craters?
  • arj0n worked on a game that was nominated for an AGS Award!
[closed] Corrupt memory when loading room (v3.4.0.16)
« Reply #6 on: 06 Jun 2017, 20:33 »
Thanx for looking into this.

The only thing I could improve at the moment is that I actually found why the program memory exception occured, and instead making it detect a wrong data error and stop loading before it does any more damage to program. So, it will still report about error, but at least that should be relatively safer now.
Glad to see it was of some use for you after-all :)

TBH I cannot imagine any particular cause right now, except for a glitch in the filesystem that returned zero file length... if that may even happen. Unless you created over 2GB room file somehow, which I doubt is possible.
No, I haven't indeed. My rooms usually stay below 1mb

Maybe if you could remember what happened just before room became corrupt.
I truly have no idea. I haven't touched that project for over a year...
It's almost unlikely to me, but one scenario that comes to my mind is that maybe I opened this project once (more then a year ago) with an alpha or beta version of ags, which might have caused this room to becoming corrupt?
Once again, unlikely. Definitely if I'm the only person having this issue so far.

Thank you again for looking into this and providing info.
I will import the room from the old build, as you suggested. :)