crazytuzi / UnrealCSharp

UnrealCSharp, based on .NET 8 (Mono), is a C# programming plugin for UE.
https://unrealcsharp.github.io/
MIT License
517 stars 77 forks source link

engine crash when using c# native string to define property in dynamic class #459

Open MingYuanLiu opened 2 hours ago

MingYuanLiu commented 2 hours ago

I define the class as shown below

namespace Script.CoreUObject
{
    [UClass]
    public partial class BP_DynamicTest_C : AActor
    {
        [UProperty, BlueprintReadWrite] 
        public string Name { get; set; }

        [UFunction, BlueprintCallable]
        public void SetName(string InName)
        {
            Name = InName;
        }
    }
}

when i finish compiling, the engine is crash dump, the crash stack is

LoginId:10a565f64833bafd8454c7b0f76485a3
EpicAccountId:c3736084582141c891b36ca63b56c508

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000040

UnrealEditor_UnrealCSharpCore!FDynamicGeneratorCore::GeneratorFunction() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicGeneratorCore.cpp:1324]
UnrealEditor_UnrealCSharpCore!FDynamicClassGenerator::ProcessGenerator() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicClassGenerator.cpp:318]
UnrealEditor_UnrealCSharpCore!FDynamicClassGenerator::GeneratorBlueprintGeneratedClass() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicClassGenerator.cpp:426]
UnrealEditor_UnrealCSharpCore!FDynamicClassGenerator::Generator() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicClassGenerator.cpp:216]
UnrealEditor_UnrealCSharpCore!FDynamicDependencyGraph::Generator() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicDependencyGraph.cpp:129]
UnrealEditor_UnrealCSharpCore!`FDynamicGenerator::Generator'::`2'::<lambda_1>::operator()() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicGenerator.cpp:30]
UnrealEditor_UnrealCSharpCore!FMonoDomainScope::FMonoDomainScope() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Public\Domain\FMonoDomainScope.h:23]
UnrealEditor_UnrealCSharpCore!FDynamicGenerator::Generator() [F:\AI_UI\XmlUI\Plugins\UnrealCSharp\Source\UnrealCSharpCore\Private\Dynamic\FDynamicGenerator.cpp:19]
UnrealEditor_Core!FModuleManager::LoadModuleWithFailureReason() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:674]
UnrealEditor_Projects!FModuleDescriptor::LoadModulesForPhase() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:696]
UnrealEditor_Projects!FPluginManager::TryLoadModulesForPlugin() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\PluginManager.cpp:2766]
UnrealEditor_Projects!FPluginManager::LoadModulesForEnabledPlugins() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\PluginManager.cpp:2903]
UnrealEditor!FEngineLoop::LoadStartupModules() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4738]
UnrealEditor!FEngineLoop::PreInitPostStartupScreen() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4000]
UnrealEditor!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:136]
UnrealEditor!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
UnrealEditor!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
UnrealEditor!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
UnrealEditor!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

i found that the cpp property is nullptr, so how can we fix it? 1731727143695

crazytuzi commented 2 hours ago

Use UE types, such as FString, instead of string