Crash when building from source with new plugin

I’m trying to import an undocumented third party plugin that uses CSpice library which was built in an older version of the engine, in order to do so I added it to my project’s Plugins folder, I deleted its Binaries and Intermediate directories, updated .sln through “Generate Visual Studio Project Files” on .uproject and tried to build it from source code in VS. It builds but once the editor is loading it always crashes at 75% when loading plugins and I get an error on “Python311.dll” and “PythonScriptPlugin”. Here’s the specific lines concerning the error, in my Saved\Logs.log file:

[2024.06.04-15.00.46:407][  0]LogPython: Using Python 3.11.8
[2024.06.04-15.00.47:398][  0]LogWindows: Error: === Critical error: ===
[2024.06.04-15.00.47:398][  0]LogWindows: Error: 
[2024.06.04-15.00.47:398][  0]LogWindows: Error: Fatal error!
[2024.06.04-15.00.47:398][  0]LogWindows: Error: 
[2024.06.04-15.00.47:398][  0]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000008
[2024.06.04-15.00.47:398][  0]LogWindows: Error: 
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd0968a970 python311.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd0968a93a python311.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffcf5434f8a UnrealEditor-PythonScriptPlugin.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffcf545462e UnrealEditor-PythonScriptPlugin.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd2a9ed2ab UnrealEditor-Core.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd24eba944 UnrealEditor-Projects.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd24ed6ec1 UnrealEditor-Projects.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffd24eba1fe UnrealEditor-Projects.dll!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7b4818 UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7b8489 UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7af556 UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7af83a UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7b2cb4 UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7c86b4 UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ff70d7cb95a UnrealEditor.exe!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: [Callstack] 0x00007ffdde30257d KERNEL32.DLL!UnknownFunction []
[2024.06.04-15.00.47:398][  0]LogWindows: Error: 
[2024.06.04-15.00.47:413][  0]LogExit: Executing StaticShutdownAfterError
[2024.06.04-15.00.47:415][  0]LogWindows: FPlatformMisc::RequestExit(1, LaunchWindowsStartup.ExceptionHandler)
[2024.06.04-15.00.47:415][  0]LogWindows: FPlatformMisc::RequestExitWithStatus(1, 3, LaunchWindowsStartup.ExceptionHandler)
[2024.06.04-15.00.47:415][  0]LogCore: Engine exit requested (reason: Win RequestExit)

in the plugin’s base dir I found a stderr.txt file that contains what follows:

Python path configuration:
  PYTHONHOME = '../../../Engine/Binaries/ThirdParty/Python3/Win64'
  PYTHONPATH = (not set)
  program name = 'C:/Users/me/Documents/Unreal Projects/MyProject/Plugins/ThirdPartyPlugin/UnrealEditor.exe'
  isolated = 1
  environment = 0
  user site = 0
  safe_path = 1
  import site = 1
  is in build tree = 0
  stdlib dir = '..\..\..\Engine\Binaries\ThirdParty\Python3\Win64\Lib'
  sys._base_executable = 'C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Binaries\\Win64\\UnrealEditor.exe'
  sys.base_prefix = '../../../Engine/Binaries/ThirdParty/Python3/Win64'
  sys.base_exec_prefix = '../../../Engine/Binaries/ThirdParty/Python3/Win64'
  sys.platlibdir = 'DLLs'
  sys.executable = 'C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Binaries\\Win64\\UnrealEditor.exe'
  sys.prefix = '../../../Engine/Binaries/ThirdParty/Python3/Win64'
  sys.exec_prefix = '../../../Engine/Binaries/ThirdParty/Python3/Win64'
  sys.path = [
    'C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Binaries\\ThirdParty\\Python3\\Win64\\',
    'C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Binaries\\Win64',

I can’t seem to find where that plugin uses python and if that might even be the problem at all, I tried to delete PythonScriptPlugin in UE_5.4\Engine\Plugins\Experimental for the sake of it and by disabling a couple modules that made use of it I managed to launch my project with the plugin, but obviously it has some blueprints that don’t compile. I noticed that now the stderr file in the plugin base dir was empty, but I guess that was because whatever python script was there just didn’t get executed. Then I reverted changes.

Another thing I noticed is that when I try to debug in VS (PythonScriptPlugin still in the engine, plugin enabled in project and everything else still there), I get the correspective of Unreal’s crash:

Exception thrown at 0x00007FFD071EA970 (python311.dll) in UnrealEditor.exe: 0xC0000005: Access violation reading location 0x0000000000000008.

But in detail also this:

python311.pdb not found.
The loaded symbol for python311.dll was ignored because it is not specified in the list of included modules.

I can’t figure out what does this mean and what should I try to do, to me it looks like some pathing problem but I can’t find errors inside the build.cs files of the plugin, if anyone has any suggestion (whatever comes to your mind) feel free to tell me, I’d try anything.

tested both on w10 and w11, with more Python versions installed other than the one inside the engine

Try running Setup.bat in your project’s root.

Epic stores the unreal engine’s Python3 distribution in its own cloud. When you run Setup.bat it will fetch this package along with other thousands of files.

You can observe this in this file: \Engine\Build\Commit.gitdeps.xml

Search “Engine/Binaries/ThirdParty/Python3/Win64”

The python distribution must be kept in-sync with your Unreal Editor executable and PythonScriptPlugin. So if you have downloaded a new source release, you must re-run Setup.bat

I don’t actually have that setup.bat in my project’s root because I didn’t build the engine from github, I just downloaded the engine from Epic Games launcher, created a project in 5.4.2 and added the external plugins in the folder Plugins

I managed to make a further step in solving the problem, at leas the crashing one, by installing the debug symbols for the editor and analyzing the call stack. By trying to isolate parts of code I got to the conclusion that the problem could have been caused by a _chdir during the Init() of the external plugin, I restored the working dir path at the end of that function and now the Editor opens without crashing and without errors (even the previously mentioned stderr.txt file now is empty).
However, now I have another problem: in the content browser there is a folder for all the plugin’s blueprints, some of these don’t compile and the errors I get are the following:

I get these in two of the Blueprints Classes objects, and in three of the Widget Blueprints

Note: GetTimeBoundariesFromFile is a function defined in the same file of the plugin that defines the Init(), and inside I can see it uses FDateTime
Maybe I should make a new post concerning the specific error in Unreal Editor I’m getting?