From a6a8cb99f572c5d1a6b81175c5bf5f14e92bc4d0 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 5 Nov 2019 15:25:00 +0200 Subject: [PATCH 1/3] Fixed: Truncated pointer on 64bit system --HG-- branch : patches-from-atys --- code/ryzom/server/src/ai_service/script_vm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/server/src/ai_service/script_vm.h b/code/ryzom/server/src/ai_service/script_vm.h index bc6e56c15..08e69034f 100644 --- a/code/ryzom/server/src/ai_service/script_vm.h +++ b/code/ryzom/server/src/ai_service/script_vm.h @@ -368,7 +368,7 @@ CScriptStack::CStackEntry& CScriptStack::CStackEntry::operator=(std::string cons { clean(); std::string* const strPt = new std::string(str); - _valp = *((int*)&strPt); + _valp = *((uintptr_t*)&strPt); _type = EString; return *this; } @@ -376,7 +376,7 @@ inline CScriptStack::CStackEntry& CScriptStack::CStackEntry::operator=(IScriptContext* sc) { clean(); - _valp = *((int*)&sc); + _valp = *((uintptr_t*)&sc); _type = EContext; return *this; } From 249ce945f1760039e0707460eeb7e65f11fdaed5 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 5 Nov 2019 18:50:54 +0200 Subject: [PATCH 2/3] Fixed: Calling member function on null object is undefined behavior. --HG-- branch : patches-from-atys --- code/ryzom/server/src/ai_service/ai_outpost.cpp | 4 ++++ code/ryzom/server/src/ai_service/ai_spire.cpp | 4 ++++ code/ryzom/server/src/ai_service/generic_logic_action.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/ryzom/server/src/ai_service/ai_outpost.cpp b/code/ryzom/server/src/ai_service/ai_outpost.cpp index bdbfd537b..385b7a849 100644 --- a/code/ryzom/server/src/ai_service/ai_outpost.cpp +++ b/code/ryzom/server/src/ai_service/ai_outpost.cpp @@ -595,6 +595,7 @@ COutpostSquadManager::COutpostSquadManager(COutpost* parent, uint32 alias, std:: eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -618,6 +619,7 @@ COutpostSquadManager::COutpostSquadManager(COutpost* parent, uint32 alias, std:: eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -641,6 +643,7 @@ COutpostSquadManager::COutpostSquadManager(COutpost* parent, uint32 alias, std:: eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -675,6 +678,7 @@ COutpostSquadManager::COutpostSquadManager(COutpost* parent, uint32 alias, std:: eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); diff --git a/code/ryzom/server/src/ai_service/ai_spire.cpp b/code/ryzom/server/src/ai_service/ai_spire.cpp index 5e2c2c05d..f53f1c1aa 100644 --- a/code/ryzom/server/src/ai_service/ai_spire.cpp +++ b/code/ryzom/server/src/ai_service/ai_spire.cpp @@ -759,6 +759,7 @@ CSpireSquadManager::CSpireSquadManager(CSpire* parent, uint32 alias, std::string eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -782,6 +783,7 @@ CSpireSquadManager::CSpireSquadManager(CSpire* parent, uint32 alias, std::string eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -805,6 +807,7 @@ CSpireSquadManager::CSpireSquadManager(CSpire* parent, uint32 alias, std::string eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); @@ -839,6 +842,7 @@ CSpireSquadManager::CSpireSquadManager(CSpire* parent, uint32 alias, std::string eventAction = NULL; // Register event handler + // FIXME: 0 == CAIAliasDescriptionNode instance event = new CAIEventReaction(getStateMachine(), 0, eventDescription.EventType); event->processEventDescription(&eventDescription, getStateMachine()); getStateMachine()->eventReactions().addChild(event); diff --git a/code/ryzom/server/src/ai_service/generic_logic_action.cpp b/code/ryzom/server/src/ai_service/generic_logic_action.cpp index a7c01d5ef..7869ffa56 100644 --- a/code/ryzom/server/src/ai_service/generic_logic_action.cpp +++ b/code/ryzom/server/src/ai_service/generic_logic_action.cpp @@ -2688,7 +2688,7 @@ CAILogicActionCode::CAILogicActionCode (const std::vector &args, c const CAIAliasDescriptionNode *eventNode, CStateMachine *container) { nldebug("loadActionCode"); - _byteCode=CCompiler::getInstance().compileCode (args, eventNode->fullName()); + _byteCode=CCompiler::getInstance().compileCode (args, eventNode ? eventNode->fullName() : "NULL"); } bool CAILogicActionCode::executeAction(CStateInstance *entity,const IAIEvent *event) From ddd0a7507edf04d4ab0cfd105431df0ce09a77d5 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 10 Nov 2019 23:23:55 +0200 Subject: [PATCH 3/3] Fixed: Invalid array access. Crash in gcc with aggressive loop optimizations enabled. --HG-- branch : patches-from-atys --- code/ryzom/server/src/ai_share/16x16_layer.cpp | 4 ++-- code/ryzom/server/src/ai_share/16x16_layer.h | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/code/ryzom/server/src/ai_share/16x16_layer.cpp b/code/ryzom/server/src/ai_share/16x16_layer.cpp index 4e78cf54e..734e4bde3 100644 --- a/code/ryzom/server/src/ai_share/16x16_layer.cpp +++ b/code/ryzom/server/src/ai_share/16x16_layer.cpp @@ -88,9 +88,9 @@ I16x16Layer *I16x16Layer::compress(I16x16Layer *layer, sint32 blank) map count; - for (i=0; i<256; ++i) + for (i=0; i<16; ++i) for (j=0;j<16;++j) { - sint32 val = flayer->Array[0][i]; + sint32 val = flayer->Array[i][j]; if (val == blank) continue; diff --git a/code/ryzom/server/src/ai_share/16x16_layer.h b/code/ryzom/server/src/ai_share/16x16_layer.h index d8c3af912..fd8853966 100644 --- a/code/ryzom/server/src/ai_share/16x16_layer.h +++ b/code/ryzom/server/src/ai_share/16x16_layer.h @@ -141,7 +141,11 @@ public: void set(uint i, uint j, sint value) { nlassert(i<16 && j<16); Array[i][j] = value; } protected: - void serial(NLMISC::IStream &f) { for (uint i=0; i<16*16; ++i) f.serial(Array[0][i]); } + void serial(NLMISC::IStream &f) { + for (uint i=0; i<16; ++i) + for (uint j=0; j<16; ++j) + f.serial(Array[i][j]); + } }; /** @@ -166,8 +170,9 @@ protected: void serial(NLMISC::IStream &f) { f.serial(Mean); - for (uint i=0; i<16*16; ++i) - f.serial(Array[0][i]); + for (uint i=0; i<16; ++i) + for(uint j=0; j<16; ++j) + f.serial(Array[i][j]); } }; @@ -193,8 +198,9 @@ protected: void serial(NLMISC::IStream &f) { f.serial(Mean); - for (uint i=0; i<16*2; ++i) - f.serial(Array[0][i]); + for (uint i=0; i<16; ++i) + for (uint j=0; j<2; ++j) + f.serial(Array[i][j]); } };