[closed] Corrupt memory when loading room (v3.4.0.16)

Started by arj0n, Sat 03/06/2017 18:12:29

Previous topic - Next topic

arj0n

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: ags

Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Version: AGS 3.4.0.16

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at load_room_file(SByte* )
   at load_crm_file(UnloadedRoom roomToLoad)
   at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
   at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
   at AGS.Editor.Components.RoomsComponent.LoadDifferentRoom(UnloadedRoom newRoom)
   at AGS.Editor.Components.RoomsComponent.LoadRoom(String controlID)
   at AGS.Editor.Components.RoomsComponent.ItemCommandClick(String controlID)
   at AGS.Editor.Components.BaseComponentWithFolders`2.CommandClick(String controlID)
   at AGS.Editor.ProjectTree.ProcessClickOnNode(String nodeID, MouseButtons button)
   at AGS.Editor.ProjectTree.projectTree_NodeMouseDoubleClick(Object sender, TreeNodeMouseClickEventArgs e)
   at System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Error MSG 2:
Code: ags

---------------------------
Adventure Game Studio
---------------------------
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.

Error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

   at load_room_file(SByte* )
   at load_crm_file(UnloadedRoom roomToLoad)
   at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
   at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
   at AGS.Editor.Components.RoomsComponent.LoadDifferentRoom(UnloadedRoom newRoom)
   at AGS.Editor.Components.RoomsComponent.LoadRoom(String controlID)
   at AGS.Editor.Components.RoomsComponent.ItemCommandClick(String controlID)
   at AGS.Editor.Components.BaseComponentWithFolders`2.CommandClick(String controlID)
   at AGS.Editor.ProjectTree.ProcessClickOnNode(String nodeID, MouseButtons button)
   at AGS.Editor.ProjectTree.projectTree_NodeMouseDoubleClick(Object sender, TreeNodeMouseClickEventArgs e)
   at System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---------------------------
OK   
---------------------------


When trying to compile the project:
Error MSG 1:
Code: ags

Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Version: AGS 3.4.0.16

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at load_room_file(SByte* )
   at load_crm_file(UnloadedRoom roomToLoad)
   at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
   at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
   at AGS.Editor.Components.RoomsComponent.RecompileAnyRoomsWhereTheScriptHasChanged(CompileMessages errors, Boolean rebuildAll)
   at AGS.Editor.Components.RoomsComponent.AGSEditor_PreCompileGame(PreCompileGameEventArgs evArgs)
   at AGS.Editor.AGSEditor.PreCompileGameHandler.Invoke(PreCompileGameEventArgs evArgs)
   at AGS.Editor.AGSEditor.CompileGame(Boolean forceRebuild, Boolean createMiniExeForDebug)
   at AGS.Editor.Components.BuildCommandsComponent.CompileGame(Boolean forceRebuild)
   at AGS.Editor.Components.BuildCommandsComponent.CommandClick(String controlID)
   at AGS.Editor.GUIController._mainForm_OnMenuClick(String menuItemID)
   at AGS.Editor.MainMenuManager.MenuEventHandler(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Error MSG 2:
Code: ags

---------------------------
Adventure Game Studio
---------------------------
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.

Error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

   at load_room_file(SByte* )
   at load_crm_file(UnloadedRoom roomToLoad)
   at AGS.Native.NativeMethods.LoadRoomFile(UnloadedRoom roomToLoad)
   at AGS.Editor.Components.RoomsComponent.LoadNewRoomIntoMemory(UnloadedRoom newRoom, CompileMessages errors)
   at AGS.Editor.Components.RoomsComponent.RecompileAnyRoomsWhereTheScriptHasChanged(CompileMessages errors, Boolean rebuildAll)
   at AGS.Editor.Components.RoomsComponent.AGSEditor_PreCompileGame(PreCompileGameEventArgs evArgs)
   at AGS.Editor.AGSEditor.PreCompileGameHandler.Invoke(PreCompileGameEventArgs evArgs)
   at AGS.Editor.AGSEditor.CompileGame(Boolean forceRebuild, Boolean createMiniExeForDebug)
   at AGS.Editor.Components.BuildCommandsComponent.CompileGame(Boolean forceRebuild)
   at AGS.Editor.Components.BuildCommandsComponent.CommandClick(String controlID)
   at AGS.Editor.GUIController._mainForm_OnMenuClick(String menuItemID)
   at AGS.Editor.MainMenuManager.MenuEventHandler(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---------------------------
OK   
---------------------------

Crimson Wizard

#1
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.

arj0n

#2
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.

Crimson Wizard

#3
Quote from: arj0n on Sat 03/06/2017 19:52:34
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)

Quote from: arj0n on Sat 03/06/2017 19:52:34
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.

arj0n

I've sent you a pm.

Quote from: Crimson Wizard on Sat 03/06/2017 20:28:10
Quote from: arj0n on Sat 03/06/2017 19:52:34
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... :)

Quote from: Crimson Wizard on Sat 03/06/2017 20:28:10
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.

Quote from: Crimson Wizard on Sat 03/06/2017 20:28:10
Quote from: arj0n on Sat 03/06/2017 19:52:34
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

#5
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.

arj0n

Thanx for looking into this.

Quote from: Crimson Wizard on Tue 06/06/2017 19:50:45
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 :)

Quote from: Crimson Wizard on Tue 06/06/2017 19:50:45
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

Quote from: Crimson Wizard on Tue 06/06/2017 19:50:45
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. :)

SMF spam blocked by CleanTalk