nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
130 stars 92 forks source link

Crash while selling #1433

Open ELadner opened 3 years ago

ELadner commented 3 years ago

The crash occurred while selling a scroll to a merchant. Maybe.

 NWNX Signal Handler:
==============================================================
 NWNX 8193.33 (c3e95f64d5) has crashed. Fatal error: Segmentation fault (11).
 Please file a bug at https://github.com/nwnxee/unified/issues
==============================================================

  Backtrace:
    /home/arabel/server/bin/linux-x86/NWNX_Core.so(_ZN7NWNXLib8Platform13GetStackTraceB5cxx11Eh+0x49) [0x7f088ea8d8d9]
    /home/arabel/server/bin/linux-x86/NWNX_Core.so(nwnx_signal_handler+0x99) [0x7f088e9de059]
    /lib/x86_64-linux-gnu/libc.so.6(<UNKNOWN>) [0x7f088d5b7fd0]
    nwserver-linux(_ZN12CNWSCreature11RequestSellEjj+0x58) [0x55c50cc24e98]
    nwserver-linux(_ZN11CNWSMessage32HandlePlayerToServerStoreMessageEP10CNWSPlayerh+0x28e) [0x55c50cdc97be]
    nwserver-linux(_ZN11CNWSMessage27HandlePlayerToServerMessageEjPhj+0x5f4) [0x55c50cddd874]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(_ZN8Profiler11NetMessages31HandlePlayerToServerMessageHookEP11CNWSMessagejPhj+0x801) [0x7f08870795f1]
    nwserver-linux(_ZN21CServerExoAppInternal13HandleMessageEjPhji+0x9d) [0x55c50cd5928d]
    nwserver-linux(_ZN19CNetLayerPlayerInfo8SetCDKeyEiRK10CExoStringS2_+0x656) [0x55c50cb519d6]
    nwserver-linux(_ZN15CNetLayerWindow23UnpacketizeFullMessagesEi+0x407) [0x55c50cb51f07]
    nwserver-linux(_ZN19CNetLayerPlayerInfo8AddCDKeyERK10CExoStringS2_+0x2d9d) [0x55c50cb605dd]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(+0x18394) [0x7f0887077394]
    nwserver-linux(_ZN21CServerExoAppInternal8MainLoopEv+0x7f) [0x55c50cd6970f]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(+0x17b36) [0x7f0887076b36]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(_ZN8Profiler8Profiler14MainLoopUpdateEP21CServerExoAppInternal+0x4c) [0x7f088707011c]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Tracking.so(_ZN8Tracking8Activity14MainLoopUpdateEP21CServerExoAppInternal+0x53) [0x7f0880a89ef3]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Util.so(<UNKNOWN>) [0x7f0880619c13]
    nwserver-linux(<UNKNOWN>) [0x55c50cae5f45]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f088d59ab97]
    nwserver-linux(_start+0x2a) [0x55c50cae9f0a]
bash: line 1: 18580 Aborted                 LD_PRELOAD=/home/arabel/server/bin/linux-x86/NWNX_Core.so nwserver-linux -port 5121 -module Arabel -servername "City Of Arabel" -userdirectory /home/arabel/nwn -interactive -publicserver 1 -maxclients 96 -minlevel 1 -maxlevel 40 -pauseandplay 0 -pvp 2 -elc 0 -ilr 0 -servervault 1 -gametype 0 -oneparty 0 -difficulty 3 -autosaveinterval 0 -dmpassword  -adminpassword  -reloadwhenempty 0 -nwsyncurl http://www.cityofarabel.com/Arabel < /home/arabel/nwn/.nwserver.pipe
ELadner commented 3 years ago

Apparently selling to ANY vendor results in a crash.

TomRotfl commented 3 years ago

Has that scroll been split manually from a player from an henchmen inventory? I had a similar case a while ago. A player found out that if you split a stack of potion into his henchmen inventory (from inside a bag), and then tried to sell the split potion, the server would crash.

I had to hook NWNX_ON_ITEM_SPLIT_BEFORE and make sure it was skipped unless the potion was inside the splitter inventory.

But it was a while ago, i still have the workaround running, not sure if necessary anymore

Daztek commented 3 years ago

Not able to repro this myself, so I dunno.

Balanor commented 3 years ago

Can confirm this happened on my server as TomRotfl described only a week ago. Ended up using the same workaround as Tom as well.

Below are some general observations from my testing that I posted on our bug report for it. I think the main problem is that when splitting an item from a container in a henchman's inventory, OBJECT_SELF in the NWNX_ON_ITEM_SPLIT event(s) is considered the PC master, not the henchman itself.


More Testing Info: This only appeared to occur when a stack was split in a container that was in a NPC Associate's inventory, which would have the split off stack go to the PC's inventory. That split stack in the PC's inventory could even be split further, but when any stack created this way was sold to store (one that was either open as this splitting happened, or even opened after this splitting), the server crash would occur. Simply splitting stacks in the NPC associate's inventory and selling them to the store directly from the NPC's inventory would not cause this, so it is technically still allowed.

More Technical Info: Oddly enough, when an item is split in a NPC's inventory, the GetItemPossessor and OBJECT_SELF doing the splitting is the NPC, at least as far as NWNX is concerned. But when an item is split in a container within an NPC Associate's inventory, the GetItemPossessor is the NPC, but OBJECT_SELF is the PC - and hence why the PC gets the split off stack that then causes the crash. Certainly doesn't seem right, and is likely part of the reason behind why the crash was occurring.

ELadner commented 3 years ago

Tried this originally with a scroll (not sure if it was split) but also tried selling a non-stackable item (a sword or ax or something like that) and also encountered the crash.

This also did not involve an NPC associate or henchman. PC selling directly to the merchant.

ELadner commented 3 years ago

Confirmed. The first item was a scroll (not part of a stack, so not split) and the second item was a halberd. Both caused same kind of crash.

ELadner commented 3 years ago

Just got this selling a helmet:

  Backtrace:
    /home/arabel/server/bin/linux-x86/NWNX_Core.so(_ZN7NWNXLib8Platform13GetStackTraceB5cxx11Eh+0x49) [0x7f941ae758d9]
    /home/arabel/server/bin/linux-x86/NWNX_Core.so(nwnx_signal_handler+0x99) [0x7f941adc6059]
    /lib/x86_64-linux-gnu/libc.so.6(<UNKNOWN>) [0x7f941999ffd0]
    nwserver-linux(_ZN12CNWSCreature11RequestSellEjj+0x58) [0x5650a6624e98]
    nwserver-linux(_ZN11CNWSMessage32HandlePlayerToServerStoreMessageEP10CNWSPlayerh+0x28e) [0x5650a67c97be]
    nwserver-linux(_ZN11CNWSMessage27HandlePlayerToServerMessageEjPhj+0x5f4) [0x5650a67dd874]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(_ZN8Profiler11NetMessages31HandlePlayerToServerMessageHookEP11CNWSMessagejPhj+0x801) [0x7f94134615f1]
    nwserver-linux(_ZN21CServerExoAppInternal13HandleMessageEjPhji+0x9d) [0x5650a675928d]
    nwserver-linux(_ZN19CNetLayerPlayerInfo8SetCDKeyEiRK10CExoStringS2_+0x656) [0x5650a65519d6]
    nwserver-linux(_ZN15CNetLayerWindow23UnpacketizeFullMessagesEi+0x407) [0x5650a6551f07]
    nwserver-linux(_ZN19CNetLayerPlayerInfo8AddCDKeyERK10CExoStringS2_+0x2d9d) [0x5650a65605dd]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(+0x18394) [0x7f941345f394]
    nwserver-linux(_ZN21CServerExoAppInternal8MainLoopEv+0x7f) [0x5650a676970f]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(+0x17b36) [0x7f941345eb36]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Profiler.so(_ZN8Profiler8Profiler14MainLoopUpdateEP21CServerExoAppInternal+0x4c) [0x7f941345811c]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Tracking.so(_ZN8Tracking8Activity14MainLoopUpdateEP21CServerExoAppInternal+0x53) [0x7f940ce71ef3]
    /home/arabel/nwnee-dedicated-8193.33/bin/linux-x86/NWNX_Util.so(<UNKNOWN>) [0x7f940ca01c13]
    nwserver-linux(<UNKNOWN>) [0x5650a64e5f45]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f9419982b97]
    nwserver-linux(_start+0x2a) [0x5650a64e9f0a]
Daztek commented 3 years ago

Have you tried a clean rebuild of nwnx + making sure your server binary is for 8193.33?

ELadner commented 3 years ago

Have you tried a clean rebuild of nwnx + making sure your server binary is for 8193.33?

Yes, this was a complete rebuild from the .33 tag. Server binary version in the original backtrace matches: NWNX 8193.33 (c3e95f64d5)

Balanor commented 3 years ago

Sounds like there are maybe two different issues here. But since I forgot to include it in my comment, I just wanted to provide the dump for the server crash caused by selling a stack split from a container in a henchmen's inventory (in case it may be useful to anyone looking into that particular issue) -

  Backtrace:
    /home/userdir/unified/Binaries/NWNX_Core.so(_ZN7NWNXLib8Platform13GetStackTraceB5cxx11Eh+0x49) [0x7f086c6738d9]
    /home/userdir/unified/Binaries/NWNX_Core.so(nwnx_signal_handler+0x99) [0x7f086c5c4059]
    /lib/x86_64-linux-gnu/libc.so.6(<UNKNOWN>) [0x7f086b1e8fd0]
    ./nwserver-linux(_ZN11CNWSMessage21WriteRepositoryUpdateEP10CNWSPlayerP10CNWSObjectP15CItemRepositoryP22CNWSPlayerLUOInventoryhch+0x1f8) [0x55dfad260e68]
    ./nwserver-linux(_ZN11CNWSMessage43WriteGameObjUpdate_MajorGUIPanels_InventoryEP10CNWSPlayerP22CNWSPlayerInventoryGUI+0x21c) [0x55dfad2757ac]
    ./nwserver-linux(_ZN11CNWSMessage33WriteGameObjUpdate_MajorGUIPanelsEP10CNWSPlayer+0x18b) [0x55dfad27aa0b]
    ./nwserver-linux(_ZN11CNWSMessage31SendServerToPlayerGameObjUpdateEP10CNWSPlayerj+0x1c0) [0x55dfad281fc0]
    ./nwserver-linux(_ZN21CServerExoAppInternal32UpdateClientGameObjectsForPlayerEP10CNWSPlayerim+0x197) [0x55dfad2a3367]
    ./nwserver-linux(_ZN21CServerExoAppInternal23UpdateClientGameObjectsEi+0x80) [0x55dfad2a3540]
    ./nwserver-linux(_ZN21CServerExoAppInternal8MainLoopEv+0x1c8) [0x55dfad2b2858]
    ./nwserver-linux(<UNKNOWN>) [0x55dfad02ef45]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f086b1cbb97]
    ./nwserver-linux(_start+0x2a) [0x55dfad032f0a]
ELadner commented 3 years ago

Does anybody have any insight into what _ZN12CNWSCreature11RequestSellEjj+0x58 is trying to do?

Also, I think the comments about splitting are confusing this issue. This problem doesn't appear to be related to the splitting issue (stack traces are wildly different).

Daztek commented 3 years ago

It checks if you can sell the item to the store, eg, not a plot item, cursed, container containing items, etc.

ELadner commented 3 years ago

Attempted to sell a plot item and a stolen item. Both also crashed the server with the exact same stacktrace.

Daztek commented 3 years ago

Does it happen with a clean module with no haks etc?

ELadner commented 3 years ago

good question. I'd have to do quite a bit of legwork to test that one. I'll see if I can whip something up this weekend.

On Thu, Oct 14, 2021 at 9:18 PM Daz @.***> wrote:

Does it happen with a clean module with no haks etc?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nwnxee/unified/issues/1433#issuecomment-943930094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4C3KWDV52SQB63VF4ZIRLUG6FOHANCNFSM5FY5LOYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Eric Ladner

ELadner commented 3 years ago

Yes.. Same crash with a simple module.

MerchantTesting.mod.gz

Daztek commented 3 years ago

Not getting a crash with that module.

I'd nuke NWNX from orbit by deleting your nwnx build files/binaries maybe the repo too and recompile it from scratch. Also delete the server binaries and grab 8193.33 again :D

mtijanic commented 3 years ago
nwserver-linux(_ZN12CNWSCreature11RequestSellEjj+0x58) [0x55c50cc24e98]

Uhh.. what? that's not at the instruction boundary..

0000000000224e40 <_ZN12CNWSCreature11RequestSellEjj>:
  224e40:       55                      push   %rbp
  224e41:       48 89 e5                mov    %rsp,%rbp
  224e44:       41 57                   push   %r15
...
  224e8d:       0f 84 bd 00 00 00       je     224f50 <_ZN12CNWSCreature11RequestSellEjj+0x110>
  224e93:       48 8b 83 e0 05 00 00    mov    0x5e0(%rbx),%rax
  224e9a:       48 85 c0                test   %rax,%rax
  224e9d:       74 0f                   je     224eae <_ZN12CNWSCreature11RequestSellEjj+0x6e>
  224e9f:       48 8b 40 10             mov    0x10(%rax),%rax
ELadner commented 3 years ago

Done. I don't know why yet, but that resolved the problem.

On Sun, Oct 17, 2021 at 2:32 PM Daz @.***> wrote:

Not getting a crash with that module.

I'd nuke NWNX from orbit by deleting your nwnx build files/binaries maybe the repo too and recompile it from scratch. Also delete the server binaries and grab 8193.33 again :D

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nwnxee/unified/issues/1433#issuecomment-945181596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4C3KQ7STPQIRTNNXF745DUHMQEHANCNFSM5FY5LOYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Eric Ladner