UPackage::SavePackage crash

I writing a plugin, with some custom functionality. I try to create a dataasset which stores some data while somebody makes changes in the editor. Its successfully creates the asset and, but when I try to call the UPackage::SavePackage it crashes the whole editor.

Here is the code:

UCoreEventRegistrySubsystem::UCoreEventRegistrySubsystem():UEngineSubsystem() {
UCustomCoreConfig* config = NewObject<UCustomCoreConfig>();

    FString packagePath = config->GetRegistryFolderPath().ToString() + "/EventRegistryData"; //The return value of the GetRegistryFolderPath is "/Game/APIConfig/Registry"

    this->Package = LoadPackage(nullptr, *packagePath, LOAD_None);
    this->Registry = FindObject<UCoreEventRegistry>(this->Package, *FString("EventRegistryData"), true);
    if (this->Registry == NULL) {
        this->Package = CreatePackage(nullptr, *packagePath);
        this->Registry = NewObject<UCoreEventRegistry>(this->Package, UCoreEventRegistry::StaticClass(), *FString("EventRegistryData"), EObjectFlags::RF_Public | EObjectFlags::RF_Standalone);



    FString assetPath = FPaths::ProjectContentDir()+"APIConfig/Registry/";
    FString FilePath = FString::Printf(TEXT("%s%s%s"), *assetPath, *FString("EventRegistryData"), *FPackageName::GetAssetPackageExtension());
    if (this->Package != NULL) {
        if (this->Registry != NULL) {
            UPackage::SavePackage(this->Package, this->Registry, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone, *FilePath, GError, nullptr, true, true, SAVE_NoError);

This is the last line in the log before the crash:
Moving ‘…/…/…/…/…/…/…/Workplace/UE4PluginDev/Saved/EventRegistryDataFA3BB2514DAC96816A94118B46A91AB7.tmp’ to ‘…/…/…/…/…/…/…/Workplace/UE4PluginDev/Content/APIConfig/Registry/EventRegistryData.uasset’

So it seems it crashes while it try to move the temp file to the target director. (I might be wrong though)

Ok, so it took me a while, but I figured it out, that it crashes because the whole code was inside an engine subsystem, and the event registry was in the loading state while I called the save. I moved my asset creation code from the constructor to a function, and I call it later when everything is ready. And I started to use UEditorAssetLibrary::SaveLoadedAsset instead of UPackage::SavePackage (the savepackage still crashes) and now it works.