So I have a private: TObjectPtr<UDataTable> EffectsDataTable
that is being static loaded by string in a UGameInstanceSubsystem::Initialize(). the dataTableRow in question has some int32s, floats, and a few Enumerations, and the DataTable is using integers as the Row Names.
the thing is when I try to access the DataTable through specific functions the DataTable is null, but in others it isn’t null. with nothing else happening in the level for the purpose of memory the Table is just null for specific function.
for example I have
// this function is called with an EXEC and works fine
void UAssetRepo::LogEntityEffects(const FString inStr)
{
UE_LOG(LogTemp, Error, TEXT("LogEntityEffects Start"));
if ( EffectsDataTable == nullptr )
{
UE_LOG(LogTemp, Error, TEXT("EntityEffectDataTable is null"));
return;
}
TArray<FName> RowNames = EffectsDataTable->GetRowNames();
int ii = 0;
for ( FName name : RowNames )
{
UE_LOG(LogTemp, Display, TEXT("%i : \"%s\""), ii++, *name.ToString());
}
const FString ContextStr(TEXT("LogAllDatatTableRows"));
for ( const FName& name : RowNames )
{
FEntityEffectRow* Row = EffectsDataTable->FindRow<FEntityEffectRow>(name, ContextStr);
if ( Row )
{
UE_LOG(LogTemp, Display, TEXT("RowName %s, Data: %s"), *name.ToString(), *Row->ToString());
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to find row with name: %s"), *name.ToString());
}
}
if ( inStr != TEXT("") && inStr.IsNumeric() )
{
// this conversion is to prove to myself that the conversion from int to FName is valid
int32 num = FCString::Atoi(*inStr);
FName RowName = FName(FString::FromInt(num));
UE_LOG(LogTemp, Display, TEXT("RowName searched for: \"%s\""), *RowName.ToString());
FEntityEffectRow* row = EffectsDataTable->FindRow<FEntityEffectRow>(RowName, ContextStr);
if ( row )
{
UE_LOG(LogTemp, Display, TEXT("RowName %s, Data: %s"), *RowName.ToString(), *row->ToString());
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to find row with name: %s"), *RowName.ToString());
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Arg invalid"));
}
UE_LOG(LogTemp, Error, TEXT("LogEntityEffects End"));;
}
then I have another function
bool UAssetRepo::GetEffectSimFromID(int32 inID, FEntityEffectSim& outResult)
{
const FName rowName = FName(FString::FromInt(inID));
UE_LOG(LogTemp, Display, TEXT("GetEffectSimFromID(\"%i\")-> \"%s\""), inID, *rowName.ToString());
// this crashes here every time.
/[101]/ if ( EffectsDataTable == nullptr )
{
UE_LOG(LogTemp, Error, TEXT("EntityEffectDataTable is null"));
return false;
}
if ( inID > INDEX_NONE )
{
if ( FEntityEffectRow* row = EffectsDataTable->FindRow<FEntityEffectRow>(rowName, TEXT("AssetRepo::GetEffectSimFromID()")) )
{
outResult = *row;
return true;
}
}
return false;
}
for testing there is only 1 element in the DataTable with a Row Name of 92; when I call the exec function with “92” it will give me the expected result:
[2024.10.21-00.40.47:512][312]Cmd: LogEntityEffects 92
[2024.10.21-00.40.47:513][312]LogTemp: Error: LogEntityEffects Start
[2024.10.21-00.40.47:513][312]LogTemp: Display: 0 : "92"
[2024.10.21-00.40.47:513][312]LogTemp: Display: RowName 92, Data: ID: 92; Amount: 2
[2024.10.21-00.40.47:513][312]LogTemp: Display: RowName searched for: "92"
[2024.10.21-00.40.47:513][312]LogTemp: Display: RowName 92, Data: ID: 92; Amount: 2
[2024.10.21-00.40.47:513][312]LogTemp: Error: LogEntityEffects End
// ...
[2024.10.21-00.42.00:774][312]LogTemp: Display: GetEffectSimFromID("92")-> "92"
[2024.10.21-00.42.02:338][477]LogWindows: Error: === Critical error: ===
[2024.10.21-00.42.02:338][477]LogWindows: Error:
[2024.10.21-00.42.02:338][477]LogWindows: Error: Fatal error!
[2024.10.21-00.42.02:338][477]LogWindows: Error:
[2024.10.21-00.42.02:338][477]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000001d8
[2024.10.21-00.42.02:338][477]LogWindows: Error:
[2024.10.21-00.42.02:338][477]LogWindows: Error: [Callstack] 0x00007ffe3895dec2 UnrealEditor-MyProject.dll!UAssetRepo::GetEffectSimFromID() [...AssetRepo.cpp:101]
no matter when I call the GetEffectSimFromID() with a valid rowName or not even if I just successfully accessed the DataTable through the exec function I get that it is when I try to get an element by RowName specifically. there is nothing going on for the GC to run away with my DataTable
so it should still be there. the AssetRepo has some Async stuff going on in it, but the DataTable is only accessed in 3 function and none of them are async so thread blocking should not the issue.
how can I narrow down what is going on, and why just this function has the DataTable as null.