Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when Python method returns a string #622

Open
dfb opened this issue Dec 8, 2018 · 1 comment · May be fixed by #626
Open

Crash when Python method returns a string #622

dfb opened this issue Dec 8, 2018 · 1 comment · May be fixed by #626

Comments

@dfb
Copy link
Contributor

dfb commented Dec 8, 2018

Given a C++ parent class like this:

UCLASS()
class UEP_CRASH_API AParentActor : public AActor
    ...
    UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) FString ReturnStr();
    UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) int ReturnInt();

and a Python subclass of it like this:

class PyChildActor(ParentActor):
    def ReturnInt(self) -> int:
        return 1234

    def ReturnStr(self) -> str:
        return 'foo'

If you place a PyChildActor in your scene and then have a different Blueprint call ReturnInt, it works. But if a Blueprint calls ReturnStr, UE4 crashes in CallPythonCallable when writing the return value into the return property:

if (ue_py_convert_pyobject(ret, return_property, frame, 0)) {

The crash is in SetPropertyValue_InContainer.

I'm using UE4.19 + Python 3.6.7 and the latest from UnrealEnginePython's master branch.

Attached is a self-contained project that demonstrates the problem. It has the C++ base class and then 2 subclasses, one in BP and one in Python. Both subclasses implement ReturnInt and ReturnStr. When you launch the game, the level BP spawn the BP subclass and calls its ReturnInt and ReturnStr methods to verify that they work. It then spawns the Python subclass and calls its same methods. The call to ReturnInt works, the call to ReturnStr triggers the crash.

uep_crash.zip

@dfb
Copy link
Contributor Author

dfb commented Dec 12, 2018

FYI I've been working on issue #621 and the fix for it seems to have fixed this problem too. I'm doing some more testing but hope to soon submit a patch for your consideration.

@dfb dfb linked a pull request Dec 12, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant