Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
57 stars 45 forks source link

Garbage Collection/Save Crash #1119

Closed slow-loki closed 5 months ago

slow-loki commented 12 months ago

I am able to force a crash upon the following conditions being met.

1) A NPC is traveling to a location with that is a known teleport 2) The destination has an item with the @step trigger enabled to remove the NPC.

Replicating the issue

1) Createt a teleport entry in any mapX_teleports.scp. 1581,1518,40=1581,1511,40=tp_lokibrit_test 2) Create a NPC with a basic function to walk to a location on creation.

[CHARDEF C_loki_test]
ID=c_man
NAME=Loki
DAM=40,50
ARMOR=200

ON=@Create
timerf 1, f_test_walk
STR=1000
DEX=400
INT=200

[FUNCTION f_test_walk]
GOTO 1581,1518,40

3)

[ITEMDEF i_loki_test_pad]
ID=i_floor_marble
name=NPC Remover
type=t_script

ON=@CREATE
attr=00090

ON=@step
IF (<SRC.ID.C_loki_test>) 
src.remove
endif

4) Place the i_loki_test_pad at location 1581,1518,40 5) Spawn a C_loki_test

The console with provide the following errors:```

22:47:DEBUG:Printing STACK TRACE for debugging purposes. 22:47:DEBUG: thread (id) name | # | function | 22:47:DEBUG:(1f00) T_Main | 0 | CWorld::_OnTick |
22:47:DEBUG:(1f00) T_Main | 1 | CObjBase::~CObjBase |
22:47:DEBUG:(1f00) T_Main | 2 | CObjBase::DeletePrepare |
22:47:DEBUG:(1f00) T_Main | 3 | CObjBase::RemoveFromView | <-- last function call (stack unwinding began here) 22:47:DEBUG:(1f00) T_Main | 4 | CObjBase::RemoveFromView |
22:47:DEBUG:(1f00) T_Main | 5 | CClient::addObjectRemove |
22:47:DEBUG:(1f00) T_Main | 6 | CClient::addObjectRemove |
22:47:DEBUG:(1f00) T_Main | 7 | PacketRemoveObject::PacketRemoveObje |
22:47:DEBUG:(1f00) T_Main | 8 | PacketSend::push |
22:47:DEBUG:(1f00) T_Main | 9 | CNetworkOutput::QueuePacket |
22:47:DEBUG:(1f00) T_Main | 10 | CNetworkOutput::QueuePacketTransacti |
22:47:DEBUG:(1f00) T_Main | 11 | CChar::Memory_FindObj |
22:47:DEBUG:(1f00) T_Main | 12 | CChar::Memory_FindObj(UID) |
22:47:DEBUG:(1f00) T_Main | 13 | CChar::Memory_FindObj(UID) |
22:47:DEBUG:(1f00) T_Main | 14 | CResourceLock::_ReadTextLine |
22:47:DEBUG:(1f00) T_Main | 15 | CItem::r_Verb |
22:47:DEBUG:(1f00) T_Main | 16 | CObjBase::r_Verb |
22:47:DEBUG:(1f00) T_Main | 17 | CScriptObj::r_Verb |
22:47:DEBUG:(1f00) T_Main | 18 | CSFileText::Close |
22:47:DEBUG:(1f00) T_Main | 19 | CSFileText::_Close |
22:47:DEBUG:(1f00) T_Main | 20 | CObjBase::Delete |
22:47:DEBUG:(1f00) T_Main | 21 | CObjBase::DeleteCleanup |
22:47:DEBUG:(1f00) T_Main | 22 | CTimedFunctionHandler::Erase |
22:47:DEBUG:(1f00) T_Main | 23 | CCharsActiveList::OnRemoveObj |
22:47:DEBUG:(1f00) T_Main | 24 | CClient::addObjectRemove |
22:47:DEBUG:(1f00) T_Main | 25 | CClient::addObjectRemove |
22:47:DEBUG:(1f00) T_Main | 26 | PacketRemoveObject::PacketRemoveObje |
22:47:DEBUG:(1f00) T_Main | 27 | PacketSend::push |
22:47:DEBUG:(1f00) T_Main | 28 | CNetworkOutput::QueuePacket |
22:47:DEBUG:(1f00) T_Main | 29 | CNetworkOutput::QueuePacketTransacti |
22:47:DEBUG:(1f00) T_Main | 30 | CScriptObj::r_GetRef |
22:47:DEBUG:(1f00) T_Main | 31 | CObjBase::r_GetRef |
22:47:DEBUG:(1f00) T_Main | 32 | CScriptObj::r_GetRef |
22:47:DEBUG:(1f00) T_Main | 33 | CExpression::GetVal |
22:47:DEBUG:(1f00) T_Main | 34 | CExpression::GetValMath |
22:47:DEBUG:(1f00) T_Main | 35 | CServer::r_GetRef |
22:47:DEBUG:(1f00) T_Main | 36 | CServerConfig::r_GetRef |
22:47:DEBUG:(1f00) T_Main | 37 | CServerConfig::ResourceGetDef |
22:47:DEBUG:(1f00) T_Main | 38 | CResourceBase::ResourceGetID_Advance |
22:47:DEBUG:(1f00) T_Main | 39 | CExpression::GetVal |
22:47:DEBUG:(1f00) T_Main | 40 | CExpression::GetValMath |
22:47:DEBUG:(1f00) T_Main | 41 | CExpression::GetValMath |
22:47:DEBUG:(1f00) T_Main | 42 | CExpression::GetValMath |
22:47:DEBUG:(1f00) T_Main | 43 | CResourceBase::ResourceGetID_Advance |
22:47:DEBUG:(1f00) T_Main | 44 | CExpression::GetVal |
22:47:DEBUG:(1f00) T_Main | 45 | CExpression::GetValMath |
22:47:CRITICAL:Assert severity=2: 'purecall' file 'unknown', line 1, in ExcType=CAssert catched in CObjBase::Cleanup in destructor()



Upon saving the server display the following error sometimes the server will crash. To force a crash spawn multiple of the NPC in quick succession.

CRITICAL:"Access Violation" (0xffff8008113ab780), in FixObj

If the @step trigger is modified to add src.timerfms 1, remove the crash/errors will not happen.

ON=@step
IF (<SRC.ID.C_loki_test>) 
src.timerfms 1, remove
endif
canerksk commented 11 months ago

+1 This had happened to me before, I solved it temporarily by turning off garbage collection.

xwerswoodx commented 11 months ago

Even I have forcegarbagecollection on, no matter how many times I tried, I get no debug at all. I did what you said exactly, even I copied your scripts directly, but still no debug, I spawned 100+ npcs to walk, still no crash happening for me. I used the src.remove one not the src.timerfms 1,remove one, just make you sure that I used correct scripts.

xwerswoodx commented 11 months ago

okay after dig this issue a bit, I found out that this issue only happens if you have NPC_AI_FOOD or NPC_AI_PERSISTENTPATH on your NPC_Flags.

slow-loki commented 11 months ago

okay after dig this issue a bit, I found out that this issue only happens if you have NPC_AI_FOOD or NPC_AI_PERSISTENTPATH on your NPC_Flags.

I can confirm I have NPC_AI_PERSISTENTPATH enabled.

xwerswoodx commented 5 months ago

I am closing this issue as noone gave a feedback for a long time, if the issue still persist please create new issue, of contact us on discord to re-open this issue.