Some ASAN fixes

This commit is contained in:
Luke Street
2026-09-04 12:54:55 -06:00
parent 6eac903b13
commit e753884773
4 changed files with 54 additions and 21 deletions
+10 -8
View File
@@ -365,14 +365,16 @@ ModResult runtime_deactivate(ModContext*, ModContext* subject, ModError*) {
return MOD_OK;
}
Vm& vm = *found->second;
DeadlineScope deadline{vm, kLifecycleBudget};
const size_t callbackCount = vm.shutdownRefs.size();
for (size_t i = callbackCount; i > 0; --i) {
std::string error;
const int ref = vm.shutdownRefs[i - 1];
if (!call_ref(vm, ref, 0, 0, kLifecycleBudget, error) && svc_log != nullptr) {
svc_log->write(subject, LOG_LEVEL_ERROR, error.c_str());
{
Vm& vm = *found->second;
DeadlineScope deadline{vm, kLifecycleBudget};
const size_t callbackCount = vm.shutdownRefs.size();
for (size_t i = callbackCount; i > 0; --i) {
std::string error;
const int ref = vm.shutdownRefs[i - 1];
if (!call_ref(vm, ref, 0, 0, kLifecycleBudget, error) && svc_log != nullptr) {
svc_log->write(subject, LOG_LEVEL_ERROR, error.c_str());
}
}
}
s_vms.erase(found);
+10 -4
View File
@@ -13,21 +13,27 @@
* modmeta records. Each IMPORT_SERVICE/EXPORT_SERVICE/DEFINE_HOOK use places one
* constant-initialized record object in the metadata section.
*/
#if defined(__has_attribute) && __has_attribute(no_sanitize)
#define MOD_META_NO_ASAN __attribute__((no_sanitize("address")))
#else
#define MOD_META_NO_ASAN
#endif
#if defined(_WIN32)
#pragma section("modmeta$a", read, write)
#pragma section("modmeta$d", read, write)
#pragma section("modmeta$z", read, write)
#if defined(__clang__)
#define MOD_META_RECORD __declspec(allocate("modmeta$d")) __attribute__((used))
#define MOD_META_RECORD __declspec(allocate("modmeta$d")) __attribute__((used)) MOD_META_NO_ASAN
#else
#define MOD_META_RECORD __declspec(allocate("modmeta$d"))
#endif
#elif defined(__APPLE__)
#define MOD_META_RECORD __attribute__((section("__DATA,__modmeta"), used))
#define MOD_META_RECORD __attribute__((section("__DATA,__modmeta"), used)) MOD_META_NO_ASAN
#elif defined(__has_attribute) && __has_attribute(retain)
#define MOD_META_RECORD __attribute__((section("modmeta"), used, retain))
#define MOD_META_RECORD __attribute__((section("modmeta"), used, retain)) MOD_META_NO_ASAN
#else
#define MOD_META_RECORD __attribute__((section("modmeta"), used))
#define MOD_META_RECORD __attribute__((section("modmeta"), used)) MOD_META_NO_ASAN
#endif
/* Section bounds for the mod_meta descriptor */
+15
View File
@@ -95,13 +95,28 @@ static void setIndirectTex(J3DModelData* i_modelData) {
for (u16 i = 0; i < texture->getNum(); i++) {
textureName = nameTab->getName(i);
#if TARGET_PC
if (textureName == NULL) {
continue;
}
if (strcmp(textureName, "fbtex_dummy") == 0) {
#else
if (memcmp(textureName, "fbtex_dummy", 0xc) == 0) {
#endif
texture->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg());
}
#if TARGET_PC
if (strcmp(textureName, "dummy") == 0) {
#else
if (memcmp(textureName, "dummy", 6) == 0) {
#endif
texture->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg());
}
#if TARGET_PC
if (strcmp(textureName, "Zbuffer") == 0) {
#else
if (memcmp(textureName, "Zbuffer", 8) == 0) {
#endif
texture->setResTIMG(i, *mDoGph_gInf_c::getZbufferTimg());
}
}
+19 -9
View File
@@ -718,13 +718,21 @@ int dShopSystem_c::itemRotate() {
return 1;
}
#if TARGET_PC
#define D_SHOP_SELECTED_ITEM_NO \
((mCursorPos > 0 && mCursorPos <= ITEM_MAX_e) ? dShopSystem_itemNo[mCursorPos - 1] : \
dItemNo_NONE_e)
#else
#define D_SHOP_SELECTED_ITEM_NO dShopSystem_itemNo[mCursorPos - 1]
#endif
int dShopSystem_c::itemZoom(cXyz* param_0) {
cXyz local_1c;
if (field_0xf60 >= 0) {
local_1c.set(*param_0);
if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_OIL_BOTTLE_e) {
if (D_SHOP_SELECTED_ITEM_NO == dItemNo_OIL_BOTTLE_e) {
mItemCtrl.setZoomAnime(mCursorPos, &local_1c,
g_cursorHIO.mSeraShopObjZoomAngleX + -5000,
isFlag(8) ? true : false);
@@ -775,9 +783,9 @@ int dShopSystem_c::itemZoom(cXyz* param_0) {
g_cursorHIO.mObjZoom.z + 150.0f);
} else {
if (mMasterType == 5) {
if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_10_e ||
dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_20_e ||
dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_30_e)
if (D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_10_e ||
D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_20_e ||
D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_30_e)
{
local_34.set(g_cursorHIO.mObjZoom.x, -50.0f + g_cursorHIO.mObjZoom.y + 5.0f,
(g_cursorHIO.mObjZoom.z + 250.0f) - 60.0f);
@@ -808,7 +816,7 @@ int dShopSystem_c::itemZoom(cXyz* param_0) {
u8 dvar1 = mMasterType;
if (dvar1 == 1) {
if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_OIL_BOTTLE_e) {
if (D_SHOP_SELECTED_ITEM_NO == dItemNo_OIL_BOTTLE_e) {
mItemCtrl.setZoomAnime(mCursorPos, &local_1c,
g_cursorHIO.mShopObjZoomAngleX + -7000,
isFlag(8) ? true : false);
@@ -817,7 +825,7 @@ int dShopSystem_c::itemZoom(cXyz* param_0) {
isFlag(8) ? true : false);
}
} else if (dvar1 == 2) {
if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_RED_BOTTLE_e) {
if (D_SHOP_SELECTED_ITEM_NO == dItemNo_RED_BOTTLE_e) {
mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mShopObjZoomAngleX - 3000,
isFlag(8) ? true : false);
} else {
@@ -825,9 +833,9 @@ int dShopSystem_c::itemZoom(cXyz* param_0) {
isFlag(8) ? true : false);
}
} else if (dvar1 == 5) {
if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_10_e ||
dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_20_e ||
dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_30_e)
if (D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_10_e ||
D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_20_e ||
D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_30_e)
{
mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mShopObjZoomAngleX - 4000,
isFlag(8) ? true : false);
@@ -850,6 +858,8 @@ int dShopSystem_c::itemZoom(cXyz* param_0) {
return 1;
}
#undef D_SHOP_SELECTED_ITEM_NO
int dShopSystem_c::seq_wait(fopAc_ac_c* param_0, dMsgFlow_c* param_1) {
return 0;
}