View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Jul 25, 2010 22:47 Post subject: UnhandledException hooking? |
|
|
Im using nwnx_funcs, nwnx_areas (both of which are revisions by Maxrock) heavily in my module, but im noticing frequent crashing, but I cant seem to put my finger on the cause of the crashes.
I was wondering if its at all possible to hook onto Exceptions in nwserver.exe and find out what script was running, to cause the exception?
All I get at the minute, is
1. Server running fine,
2. I go away for dinner,
3. Come back 30 minutes later
4. Find nwnx restarted a locked up server, and there is still a Microsoft error report msg box on screen, saying that an error occured in nwserver.exe.
Unfortunately, the logs arent that useful, because while they are set to level 3 etc or the max setting, they dont tend to keep track of the time or date of the function calls.
And even more annoyingly, because nwnx kept running dispite of the crash, the logs just get appended onto eachother seamlessly, meaning its impossible to tell where the crash occured in the nwnx funcs log file.
Can anyone suggest possible diagnostic methods to finding causes of crashes?
Im about to start putting in Debug Messages at the start of all the functions I suspect are causing crashes.
Eg
Code: |
void DestroyArea(object oArea)
{
WriteTimeStampedLogEntry("Starting Destroy Area on:"+GetName(oArea)+":"+GetResRef(oArea)+":"+GetTag(oArea));
//Original Code here
//End of Original Code here
WriteTimeStampedLogEntry("Finished Destroy Area on:"+GetName(oArea)+":"+GetResRef(oArea)+":"+GetTag(oArea));
}
|
I will obviously put a wrapper in instead, which will exclude the logging, if DebugMode is set to off etc.
If anyone can suggest possible courses of action, please by all means. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Jul 25, 2010 23:03 Post subject: |
|
|
Anyway.... I think this may have belonged in the tech support,
but the question stands.
Does anyone thing its possible to create a nwnx plugin, which could actually get more detailed explanations of exceptions caused in nwn?
Eg - In C# you can use a try and catch statement to display error boxes with the cause of the crash, and sometimes the name of the function.
Is anything like that possible here?
Or,
If I take note of the Offset of the error, am I able to look this up in IDA to get a better idea of what function crashed? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 0:24 Post subject: Note - Server just crashed |
|
|
Offset:0000b876
But the cause of the error is still a mystery to me...
Quote: |
Connection Attempt made by TheMadPoetGaussalin (XXXXYYYY)
[Sun Jul 25 22:48:09] PLAYER (XXXXYYYY) Joined as Player 1
[Sun Jul 25 22:52:37] Starting LoadArea Function with ResRef:awakeninginmerid
[Sun Jul 25 22:52:37] Ending LoadArea Function with ResRef:awakeninginmerid
[Sun Jul 25 22:57:35] PLAYER Left as a Player (0 players left)
[Sun Jul 25 22:57:40] Starting DestroyArea Function with area:Awakening in Meridian:awakeninginmerid:AwakeninginMeridian
[Sun Jul 25 22:57:40] Finishing DestroyArea Function
Connection Attempt made by Baaleos (XXXXYYYY)
[Sun Jul 25 23:13:54] Baaleos (XXXXYYYY) Joined as Player 1
SERVER CRASH HERE <<-----
|
I have the debug messages inside the nwnx_area functions themselves, before and after the SetLocalStrings etc.
But according to this, it didnt even get as far as entering the function let alone setting any local vars to trigger a nwnx call.
The character I had just made, was a new character.
Really confused, because
But 0000b876 seems like a very early position in nwserver for it to have crashed at.
B876 Appears to be
CExoString::CExoString
Not even a function really, its a data type isnt it or a struct? |
|
Back to top |
|
|
MaxRock
Joined: 24 Jan 2008 Posts: 196
|
Posted: Mon Jul 26, 2010 3:15 Post subject: |
|
|
CExoString::CExoString is one of the constructors for the string class.
And a crash at that point actually looks familiar...
There is a problem with destroying areas in which characters have logged out; although I thought I had fixed that...
try adding this to nwnx.ini Code: |
[AREAS]
debugLevel=3
LocationFailSafe = LocationFailSafe
|
LocationFailSafe is the name of a local location var which is used when an area doesn't exist anymore.
Set it before any players log on:
Code: | SetLocalLocation(GetModule(), "LocationFailSafe", GetStartingLocation()); |
By default the name/string (which is an ExoString) is empty and I don't catch that
If that doesn't fix it, grab the latest nwnx_funcs (0.8.3) and do what you did (log off, destroy area) but before you log back in run Code: | NWNXFuncs_ClearTURDList() |
If it crashes at this point then there's probably something wrong with nwnx_areas. If not, try to log the character back in. If it crashes then ... there's something wrong with nwnx_areas, uhm.
Let me know which one it is.
Edit:
I have no clue what that memory adress is for. When I installed Visual Studio 6 it pretty much took over any application that crashes and ask if I want to debug it. Clicking yes there usually gives me a "good" address. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 3:23 Post subject: I will give that a go |
|
|
One of my players was just saying to me, that the server seemed to crash just as I had logged out.
I purposely designed our 'Spectral Realm' system to destroy the spectral copies of areas, when the Material Realm version of that area was also empty.
To prevent a player from transitioning into the spectral realm, as it is being destroyed (a player did this, then ended up in limbo - BLACK).
Eg - if they are in the material realm original of the spectral realm copy, then there exists the possibility of them transitioning into the spectral realm in one transition or less.
So I decided to keep the spectral realm around, and keep checking to see if the material realm original becomes empty, and when it does, then it safely deletes itself.
Clearly it didnt seem to want to do this.
So, just to clarify,
You want me to put this
SetLocalLocation(GetModule(), "LocationFailSafe", GetStartingLocation());
in the onClient Exit code of the module?
Oh... theres something I never thought about...
What if a player logs out inside the Spectral Realm.... darn...
Im gonna have to script it so that onClientExit, it determines if its in the spectral realm. Lol
This is a video of the spectral realm, you have heard so much about in this post. It is reliant on the nwnx_areas plugin.
http://www.youtube.com/watch?v=uLX5jpTYSGg |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 3:27 Post subject: |
|
|
just re-read that.
So set the failsafe, on the onModLoad event? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 3:33 Post subject: |
|
|
nwnx_funcs isnt building.
Think you forgot to include
Quote: |
1>c1xx : fatal error C1083: Cannot open source file: '..\nwn_internals\CNWSplayerTURD.cpp': No such file or directory
|
in the include folder?
I also get the following build errors
Quote: |
1>.\funcs_def.cpp(3289) : error C2039: 'mod_PlayerTURDList' : is not a member of 'CNWSModule_s'
1> c:\documents and settings\administrator.jpc.003\desktop\nwnx2-win32\branches\maxrock\include\.\CNWSModule.h(4) : see declaration of 'CNWSModule_s'
1>.\funcs_def.cpp(3289) : error C2228: left of '.GetHeadPos' must have class/struct/union
1>.\funcs_def.cpp(3292) : error C2039: 'mod_PlayerTURDList' : is not a member of 'CNWSModule_s'
1> c:\documents and settings\administrator.jpc.003\desktop\nwnx2-win32\branches\maxrock\include\.\CNWSModule.h(4) : see declaration of 'CNWSModule_s'
1>.\funcs_def.cpp(3292) : error C2228: left of '.Remove' must have class/struct/union
1>.\funcs_def.cpp(3294) : error C2039: 'ScalarDestructor' : is not a member of 'CNWSPlayerTURD_s'
1> c:\documents and settings\administrator.jpc.003\desktop\nwnx2-win32\branches\maxrock\include\.\CNWSPlayerTURD.h(4) : see declaration of 'CNWSPlayerTURD_s'
1>.\funcs_def.cpp(3296) : error C2039: 'mod_PlayerTURDList' : is not a member of 'CNWSModule_s'
1> c:\documents and settings\administrator.jpc.003\desktop\nwnx2-win32\branches\maxrock\include\.\CNWSModule.h(4) : see declaration of 'CNWSModule_s'
1>.\funcs_def.cpp(3296) : error C2228: left of '.GetHeadPos' must have class/struct/union
|
|
|
Back to top |
|
|
MaxRock
Joined: 24 Jan 2008 Posts: 196
|
Posted: Mon Jul 26, 2010 4:04 Post subject: |
|
|
Ack, you're right, I didn't commit the classes and includes. Should be there now.
Edit: Quote: |
So, just to clarify,
You want me to put this
SetLocalLocation(GetModule(), "LocationFailSafe", GetStartingLocation()); |
No I want you to put that in OnModuleLoad actually.
Alright, let's see if I can get it together:
Between resets the server keeps its own persistency, right? It's most notable with location: You only go through the StartingLocation area once.
This - and a bunch of other stuff - is stored when a character logs off.
Since the vanilla game doesn't account for areas being destroyed there is no check for area validity on logon so if the area is gone it dereferences an invalid pointer and the server goes byebye.
What I tried to do is provide a failsafe for those occurences: If the area is invalid it checks the module for that local location and ports the character there. ...actually I think it checks the character for a personal failsafe location first. Anyways, you can set the variable name in nwnx.ini Code: |
[AREAS]
debugLevel=3
LocationFailSafe = MyFailsafeLocationThisIs
|
Then in OnModuleLoad Code: |
SetLocalLocation(GetModule(), "LocationFailSafe", GetStartingLocation()); |
You can of course use any location you want.
Or set the same local location on the character; I do this with our Mordenkainen's Magnificent Mansion spell, just before the characters get sucked in.
The problem is that if you don't have the AREAS section set in nwnx.ini the location var name stays empty and we go through the whole invalid area -> server crash thing again.
Last edited by MaxRock on Mon Jul 26, 2010 4:23; edited 1 time in total |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 4:08 Post subject: |
|
|
k, its terrible when im right isnt it. Lol
I also confirmed my fears that players can cause crashes, if they leave an area via disconnect, area is destroyed, then they rejoin in that erased area.
The error occurs in
offset 123161 - the CNWSTile:GetLocation() function.
I guess im gonna have to be more creative about my approach to destroying areas, or determining when is safe to destroy areas.
The only problem, is that there is no way to differentiate between leaving the area, and leaving the module, since leaving the module, calls the areaLeave event too.
Leaving the Area = Good, Can delete
Leaving the Module = Bad, should keep the area just incase.
Alternativly, if it were possible to resend the player to StartLocation in the event his area doesnt exist.
This cant be done with simple nwnscript, since GetLocation gets called before nwnscript can be called. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Jul 26, 2010 4:11 Post subject: |
|
|
Anyway, I just did a test of the FailSafeLocation set, and no apparent crashes, but that being said, It was just me in the server at this time.
Tomorrow I will get a few people in, and see if we can cause some crashes.
Note - The nwnx_funcs.dll builds fine now.
Is there an nss with it -..... found it.
NWNXFuncs_ClearPlayerTURDs() Looks like it might fix my problems, to a degree - it would prevent players from reappearing in areas that dont exist, but its a pitty that its a global / all player affecting function.
Is it possible to access the stored data, such as player locations etc stored on the server?
Would it be possible to change this data, after the player is gone? |
|
Back to top |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|