Crash error: Exception was “Access violation - code c0000005 (first/second chance not available)”
Last two lines of call stack: UE4Editor_OrtCloud!AOrtCloudAIController::Tick() [f:\documents\unreal projects\ortcloud\source\ortcloud\ortcloudaicontroller.cpp:88]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\actor.cpp:107]
Call stack says its line 88. GetOrtPawn() is a function that either returns an OrtPawn or NULL.
This entire block of code is wrapped in an if/then that checks if OrtPawn exists.
It seems to me, the only possible option on line 88 is GetOrtPawn()->CoreSection, which has been checked on line 86 and has to have PASSED in order to even get to line 88.
When you say “Uninitialized pointers will pass a null / nullptr condition” do you mean:
Uninitialized pointers will be considered null/nullptr by the if check?
or
Uninitialized pointers will be considered passed(return true) by the if check?
EDIT:
CoreSection can indeed be uninitialized when the code runs this block.
So if you mean 2 that would explain why it is passing line 86 and crashing at subsequent parts of the if check.
If you have a valid reference to a class which has a uninitialized pointer in it and you try to access it, it will give you an access validation. If you have a valid reference to a class and you have a condition for the uninitialized pointer in that class, it will evaluate as true, if it is follows:
if(GetOrtPawn()->CoreSection)
{
// CoreSection can be uninitialized and still pass this condition.
}
You can solve this by setting CoreSection to NULL or nullptr in the constructor of your OrtPawn class.
**A broader example: **
class MyTestClass
{
public:
MyTestClass() {}
int ID;
};
class MyOtherTestClass
{
public:
MyOtherTestClass(){}
MyTestClass *ChildClass;
float Area;
};
void TestingFunction()
{
MyOtherTestClass *Testing = new MyOtherTestClass( );
if(Testing)
{
if(Testing->ChildClass)
{
// Passes condition even though "TestingClass" is unitialized
printf("passes condition
");
// Crashes
printf("%d", Testing->ChildClass->ID);
}
}
delete Testing;
}