logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
NWNX Chat crashes Server
Goto page Previous  1, 2
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Tue Aug 20, 2013 19:43    Post subject: Reply with quote

I really should check these forums more often Smile

Good find Terra! That explains why when I pushed the arg onto Parameters (memory already allocated by nwnserver) instead of allocating more it fixed the crash.

I went to the debugger to go after the SendChatMsg() crash, thinking that the problem was with the stack alignment since 1.69. No wonder why I couldn't find anything - maybe it has to do with the mem. This week I'll come up with a new angle.

Hopefully I can get a 64-bit compatible version of this plugin done so I can move on with my nwnx64 project. Out of all the compat issues I've looked at so far, this one has been the worst.
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Tue Aug 20, 2013 20:04    Post subject: Reply with quote

Have you looked at nwnx areas? I've tried porting max rocks version to be 64 bit compatible but I've had no such luck but I think it has more to do with forgetting or doing something wrong rather.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Tue Aug 20, 2013 20:11    Post subject: Reply with quote

Sorry, haven't gotten to that one yet Smile I do have Max Rock's codes used in mine but I left the area plugin out (among many) until I could vet each of them one by one.

btw in my last post (I was coming back for a ninja edit) I probably was a little confusing... its a 32 bit application, just aiming for 64 bit os compatibility - its not actually a 64-bit nwnx. This largely means removing madCHook or finding a new one. I have my own codes, virusman likes MS Detours.

Generally the biggest compat issue I've found is the madCHook dependency.
Back to top
View user's profile Send private message
highv priest



Joined: 01 Mar 2013
Posts: 111

PostPosted: Tue Aug 20, 2013 20:20    Post subject: Reply with quote

NWNX_AREAS doesn't work? Hmm I hadn't tried that one yet, but I was considering it(mostly for the ability to have multiple instances to avoid syncing issues, such as cutscene moments).
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Tue Aug 20, 2013 22:18    Post subject: Reply with quote

From what I understand, heap management is shared if everything links to the same msvcrtxx.dll or wherever the hell they keep it these days. Statically compiling in different instances can result in multiple heap managers.

I really don't know what happened from XP to Win7 pro, but I do know odbc2, nwnx_cool, time, profiler, nwnx_funcs, ALL return null in OnRequest() and thereby do not return back any pointers, so that might explain why not many plugins have tripped it.

Anecdotally so far, I have found switching out the malloc/free pair for the HeapAlloc/HeapFree functions seems to fix it.
Back to top
View user's profile Send private message
highv priest



Joined: 01 Mar 2013
Posts: 111

PostPosted: Wed Aug 21, 2013 20:01    Post subject: Reply with quote

Ah I can give a list of the windows plugins I use that I KNOW do work despite this, including one which apparently probably shouldn't if it's an issue of memory allocation.


Letoscript

Events

Fixes

hashset(this is the one o.o)

ODBC

Reset

Resman

systemdata32

I have pretty much all of them, but these are the ones I've actually used so far. A pre-emptive question I suppose, I was considering on using hashset to store creature IDs for faster retrieval by using GetObjectByID(from Terra's NWNX_COOL). Will this crash the server?
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Thu Aug 22, 2013 2:19    Post subject: Reply with quote

Thats not really what I was talking about highpriest. It's really *my* bad because a lot of the things I'm writing in this thread belongs in "Windows Development" forum than "Windows Support" forum. Forgive my poor forum etiquette.

Since its already corrupted, I'll just keep going Smile

I discovered today after blowing up 8 hours of solid debugging on m yday off that..... NWN uses HeapFree() for its chat messages, or at least its ones in the server window.

dun-dun-dun-dun!

In fact, I think its in the destructor for most of their CExoStrings which they use for it, so I'd bank on it universally (or close to it).

.text:00602642 call ds:HeapFree


More at 11. When crafting a CExoString, the character pointer component should use the corresponding HeapAlloc and not malloc.

MaxRock's implementation uses new(), which probably explains a lot since malloc() does most of the heavy lifting for that on a lower level. It may have actually worked once upon a time on XP if the heapmanagers could mix and match like that - not sure. The Windows 7 memory model does seem more strict...
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Thu Aug 22, 2013 3:36    Post subject: Reply with quote

Do believe cool should work since I've been using function pointers to nwservers malloc/free. Generally any plugin that does not free or allocate any memory within nwserver will work. Read/Write on nwserver allocated memory is fine.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Fri Aug 23, 2013 8:54    Post subject: Reply with quote

Correct, Tera. Cool is good, and NWN hates any memory fed to it. Until now -- I think -- I've managed to "go there" and mess with their memory. As it turns out, they call HeapCreate() and store the heap pointer as a global variable - I read this pointer out of memory, and use it to point to the same heap and use HeapAlloc from THEIR heap, thus allowing memory passed back to NWN to be free'd by NWN without a crash, since it will free from the same heap. Its really quite neat.

Anyway, I've fixed Chat and it should be the highest and best version of Chat available. I got to tidy up the documentation and I also got to test compatibility for some extenuating chat cases, so that remains. When I'm done, I'll post it with the source code and any interested parties can see how it was done.

For the record, their heap pointer ias a 4 byte address at 0x5EEFF00....
The value is not static; it changes everytime NWN server starts, so it must be read after it calls HeapCreate(). Using GetProcessHeap() will NOT return the correct heap, since Bioware had to go and make their own.....
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Aug 26, 2013 19:34    Post subject: Reply with quote

Hey Addicted -
Would this issue be why my module was working on Windows server 2003, but then stopped working on Windows Server 2008 and onwards?

Windows 2008+ does seem more windows 7-ish , and windows 2003 server is kinda xp-ish : just wondering if that's a possible reason?

The issue seems related to nwnx chat - and it always causes crashes in ntdll.dll.


Im eagerly awaiting a copy of your nwnx chat plugin - hoping that it will solve my problems.
I tried porting my module to Linux - but that just created more problems - because a lot of the plugins use different implimentations and areas plugin seems a little dodgy.
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Mon Aug 26, 2013 21:43    Post subject: Reply with quote

Baaleos wrote:
Hey Addicted -
Would this issue be why my module was working on Windows server 2003, but then stopped working on Windows Server 2008 and onwards?

Windows 2008+ does seem more windows 7-ish , and windows 2003 server is kinda xp-ish : just wondering if that's a possible reason?

The issue seems related to nwnx chat - and it always causes crashes in ntdll.dll.


Im eagerly awaiting a copy of your nwnx chat plugin - hoping that it will solve my problems.
I tried porting my module to Linux - but that just created more problems - because a lot of the plugins use different implimentations and areas plugin seems a little dodgy.


I definitely think so. My conclusion on this thread is represented as a new thread here - http://www.nwnx.org/phpBB2/viewtopic.php?t=2109

Try the full source download (it has several binaries in it, including a nwnx.exe for 64-bit compat). Give it a shot on your windows 2008 system. I'm interested to see how it pans out.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Aug 16, 2014 17:00    Post subject: Reply with quote

only solution found so far is to run the nwserver / nwnx on a windows 2003 server or below
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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


Powered by phpBB © 2001, 2005 phpBB Group