PropertyWatcher icon indicating copy to clipboard operation
PropertyWatcher copied to clipboard

access violation when reading name

Open MicalKarl opened this issue 1 year ago • 4 comments

FAView TempMemoryPool::NToA(FName Name) {
	const FNameEntry* NameEntry = Name.GetDisplayNameEntry();
	if (NameEntry->IsWide())
		return "<WideFNameError>";

Error occurs at NameEntry->IsWide() where the Name value shows Illegal name (block index out of range)_3

I guess the errs might be Ptr or StructPtr is invalid in the bellowing code.

FName PropertyItem::GetName() {
	if (Type == PointerType::Property && Prop)
		return Prop->GetFName();

	if (Type == PointerType::Object && Ptr)
		return ((UObject*)Ptr)->GetFName();

	if (StructPtr && (Type == PointerType::Struct || Type == PointerType::Function))
		return StructPtr->GetFName();
		//return StructPtr->GetAuthoredName();

	return NAME_None;
}

MicalKarl avatar Oct 19 '23 12:10 MicalKarl

Thank you for the bug report! (And sorry for the crash.) I will look at it on the weekend at the latest. Is there an easy way for me to reproduce the crash? What kind of object did you look at in the watch window?

guitarfreak avatar Oct 19 '23 17:10 guitarfreak

Thank you for the bug report! (And sorry for the crash.) I will look at it on the weekend at the latest. Is there an easy way for me to reproduce the crash? What kind of object did you look at in the watch window?

Thanks for your reply! I encountered this issue when clicking the properties of an actor deeply like a player state (I forget which type of actor it is), but I remember the issue property type is an Object type, I fixed it myself with a TWeakObjectPtr check when using PropertyItem::GetName() function.

MicalKarl avatar Oct 20 '23 02:10 MicalKarl

Interesting, we do check if a TWeakObjectPtr is stale before drawing it.

} else if (FWeakObjectProperty* WeakObjProp = CastField<FWeakObjectProperty>(Item.Prop)) {
	TWeakObjectPtr<UObject>* WeakPtr = (TWeakObjectPtr<UObject>*)Item.Ptr;
	if (WeakPtr->IsStale())
		ImGui::Text("<Stale>");
	if (!WeakPtr->IsValid())
		ImGui::Text("<Null>");
	else {
		auto NewItem = MakeObjectItem(WeakPtr->Get());
		DrawPropertyValue(NewItem);
	}

Maybe it got destroyed while DrawPropertyValue happened? If that's possible I would have to restructure the code a bit, because currently only the raw object pointer gets passed down without the "weak" part. How did you fix it exactly?

guitarfreak avatar Oct 22 '23 10:10 guitarfreak

Interesting, we do check if a TWeakObjectPtr is stale before drawing it.

} else if (FWeakObjectProperty* WeakObjProp = CastField<FWeakObjectProperty>(Item.Prop)) {
	TWeakObjectPtr<UObject>* WeakPtr = (TWeakObjectPtr<UObject>*)Item.Ptr;
	if (WeakPtr->IsStale())
		ImGui::Text("<Stale>");
	if (!WeakPtr->IsValid())
		ImGui::Text("<Null>");
	else {
		auto NewItem = MakeObjectItem(WeakPtr->Get());
		DrawPropertyValue(NewItem);
	}

Maybe it got destroyed while DrawPropertyValue happened? If that's possible I would have to restructure the code a bit, because currently only the raw object pointer gets passed down without the "weak" part. How did you fix it exactly?

I fix it simply by when construting the PropertyItem struct, add a TWeakObjectPtr to watch if it is a uobject. When it comes to use the raw _Ptr value, check it if valid.

MicalKarl avatar Oct 23 '23 03:10 MicalKarl