Cause of UE-48712

This is more of an answer that hopefully people whom are suffering from the same problem may find useful rather than a question.

First let’s start with the problem itself. As you may well see in the issue UE-48712 there is a fairly common error in Unreal which was haunting me for a really longtime.

I’ll start with the way the problem occurred. After maintaining and adding new features to our product built on UE4, we’ve seen after some time that adding code caused this error where there which would cause no compile-time errors but would cause a runtime crash on the launcher.

Experimenting with the issue, I’ve seen that even writing comments with 0 added lines of code differing from the last working commit would cause the same crash. Which got me thinking about the unity build of Unreal where different cpps get included into same file and compiled rather that all of them being compiled one by one. Adding codes or even comments could cause different pagings of cpps where the last cpp in page may be included into the next according to the size of it.

After comparing these generated pages (in my case inside Intermediate->Build->Win64->UE4Editor->Configuration->ModuleName) between crashing and last healthy builds, I’ve seen that the last CPP that would get included into next page had #pragma pack directives which was causing the issue.

Anyone facing this problem, I suggest you do the same and check what changes in the unreal unity build between healthy and crashing build, It is probable that you will find unpoped pragma packs are what causing the issue.