UEnum from uint8 has no hash function?

I attempted to use a C+±defined enum as a key in a Map. It compiled without any problems and seemed to work without issue until I reopened the project later. From then on, if I tried to open the file, or even right-click it the engine would crash with the following:

Assertion failed: PropertyFlags & CPF_HasGetValueTypeHash [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Property.cpp] [Line: 1240] 

The enum itself was defined in a BlueprintFunctionLibrary in C++ called Constants.h as follows:

UENUM(BlueprintType)
enum class EKoro : uint8
{
	None	UMETA(DisplayName = "None"),
	Ta		UMETA(DisplayName = "Ta"),
	Ko		UMETA(DisplayName = "Ko"),
	Ga		UMETA(DisplayName = "Ga"),
	Po		UMETA(DisplayName = "Po"),
	Onu		UMETA(DisplayName = "Onu"),
	Le		UMETA(DisplayName = "Le"),
	Av		UMETA(DisplayName = "Av"),
	Kra		UMETA(DisplayName = "Kra"),
	Ba		UMETA(DisplayName = "Ba"),
	Bo		UMETA(DisplayName = "Bo"),
	Ce		UMETA(DisplayName = "Ce"),
	De		UMETA(DisplayName = "De"),
	Fa		UMETA(DisplayName = "Fa"),
	Fe		UMETA(DisplayName = "Fe"),
	Su		UMETA(DisplayName = "Su"),
	Vo		UMETA(DisplayName = "Vo")	
};

I tried it with another Enum as well; defined in a similar manner (in the same file), and it also crashed the engine. Therefore, it appears there is some issue with hashing C++ defined enums, and because it inherits from uint8, it seems there must be an issue trying to hash that as well.

It should be noted that the engine does not crash, from my limited experiment, if the enum is defined in BP.

I’m not sure if this is a bug or if I’m just missing something, but I’m assuming it’s something that the engine should handle differently than simply crashing with a sort of vague error.

Thanks for any help that can be provided, if any.

Hey Inferno630-

Can you explain what you mean when you say you used the enum as a key in a map? I copied the Enum you provided into a new class however I’m not sure what you’re doing at this ponit. If possible, please provide the steps for how you set this up so I can test the same setup locally. Additionally, the full crash report and log files from the crash would be helpful in identifying the cause.

No problem. I created a new UMG Widget in the Editor (and added a Map variable with the Key being the enum and the Value being a String, like in this image)

129975-crashmap.png

Then, I compiled the file, saved, and closed the project (this crash only occurs after the project is closed and then reopened; everything functions normally before then).

Lastly, I reopened the project, and then tried to open the file, which is when the crash occurred (the crash will also occur if you right-click the file).

I included the full crash report in the attached file crashlogs.zip, with the name Z_FullCrashReport.txt. I’m fairly certain those are all of the crash logs you asked for, but if there are additional files you need, please let me know. [link text][2]

Please let me know if you need any more information in general, as well.

Hey Inerno630-

Thank you for the clarification, I was able to reproduce the crash you described and have entered a report for it here Unreal Engine Issues and Bug Tracker (UE-42865) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

1 Like

I’ve run into this same issue now as well. I just lost two large blueprints because of it. I can no longer open the blueprints or even delete them from the editor as that crashes it too! I had to manually delete them from the file system. Now I have to spend an entire day redoing them!!!

I notice though that the bug report has been marked as “Won’t Fix.” However there is no comment as to why it has been marked that. Can we get a reason as to why this crash won’t be fixed?

I can understand if Epic doesn’t want to implement the functionality to use custom enums in a Map/Set. However, you guys can’t leave it the way it is. It is far too dangerous as there is no warning given or anything and you only discover that you’ve lost all your work after you close and reopen the editor.

At the very least can you put some sort of catch in when the user tries to use a custom enum in a Map/Set. Have it display an error and stop them from setting it please. You can’t leave a crash case that destroys your project in there. Please.

Hey -

UE-42865 was marked as a Won’t Fix because it was a duplicate of another bug being tracked (UE-42441). UE-42441 has been verified as fixed for 4.16. I have added a note to UE-42865 to indicate this.

Right, ok then. Ignore my above rant then… LOL.

Hey ,

are you sure this bug is a duplicate of UE-42441? I don’t think so.

UE-42441 is specifically about Structs. Structs can define their own GetTypeHash() function that defines how they are hashed. Enums are different. UE-42441 does not mention enums at all.

So I think UE-42441 is a completely different issue that’s not related to this one.

For anyone seeing this issue, you can workaround it in the source so that you can open the affected blueprint and then delete the Map variable.

Simple find the Property.cpp file in the UE4 source and replace everything in the

UProperty::GetValueTypeHash(const void* Src) const

function with:

	// make sure the type is hashable
	if (PropertyFlags & CPF_HasGetValueTypeHash) {
		check(Src);
		return GetValueTypeHashInternal(Src);
	}

	return 0;

You can keep the code in there, it doesn’t have any negative side effects, it just prevents the engine from crashing :slight_smile:

Hey -

Thank you for providing a workaround for the issue. Though the reproduction is different for the two issues, the underlying root for both are the same.

He addressed your question, saying the bug was fixed in the next version.

Why should he address your whiney rant? Your outrage adds nothing to the process of tracking this bug.