x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[4.6.1] Crash when BlueprintCallable method returns TWeakObjectPtr

When I call a function from blueprint (UI in this case) and the function returns a TWeakObjectPtr it crashes. Replacing it with a regular pointer fixes the issue, but the compiler does not produce an error as it does with parameters.

 Access violation - code c0000005 (first/second chance not available)
 
 UE4Editor_CoreUObject + 1643774 bytes
 UE4Editor_CoreUObject + 716678 bytes
 UE4Editor_CoreUObject + 1616623 bytes
 UE4Editor_CoreUObject + 1477214 bytes
 UE4Editor_CoreUObject + 1350042 bytes
 UE4Editor_CoreUObject + 1621364 bytes
 UE4Editor_CoreUObject + 1477214 bytes
 UE4Editor_CoreUObject + 563956 bytes
 UE4Editor_CoreUObject + 1475014 bytes
 UE4Editor_UMG + 141702 bytes
 UE4Editor_UMG + 883535 bytes
 UE4Editor_UMG + 53187 bytes
 UE4Editor_UMG + 60825 bytes
 UE4Editor_UMG + 541413 bytes
 UE4Editor_Slate + 2116506 bytes
 UE4Editor_Slate + 2296435 bytes
 UE4Editor_Slate + 432060 bytes
 UE4Editor_Slate + 160583 bytes
 UE4Editor_Slate + 832224 bytes
 UE4Editor_Slate + 770598 bytes
 UE4Editor_Core + 2484713 bytes
 UE4Editor_Core + 2400763 bytes
 UE4Editor_Core + 2489275 bytes
 UE4Editor_Core + 2387186 bytes
 user32 + 105425 bytes
 user32 + 104666 bytes
 UE4Editor_Core + 2490486 bytes
 UE4Editor!FEngineLoop::Tick() + 3434 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launchengineloop.cpp:2193]
 UE4Editor!GuardedMain() + 479 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launch.cpp:131]
 UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
 UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
 UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
 

Debugger spits this out as well:

 First-chance exception at 0x000007FEE74A14FE (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x000000010000000B.
 Unhandled exception at 0x000007FEE74A14FE (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x000000010000000B.
 

greetings,

FTC

Product Version: Not Selected
Tags:
more ▼

asked Feb 20 '15 at 02:15 PM in Bug Reports

avatar image

FTC
171 6 11 15

avatar image Jonathan Dorman STAFF Feb 23 '15 at 07:45 PM

Hey FTC,

Does this crash also occur in the 4.7 preview?

avatar image FTC Feb 24 '15 at 09:42 AM

Hey Jonathan,

yes it does (I am on preview 8). This is my quick and dirty test function:

 UFUNCTION(BlueprintCallable, Category="test")
 TWeakObjectPtr<AActor> Bla();


 TWeakObjectPtr<AActor> AMyTestActor::Bla()
 {
     auto Actor = GetWorld()->SpawnActor<AStaticMeshActor>();
     return TWeakObjectPtr<AActor>(Actor);
 }



It also crashes if the return value is not newly spawned, but instead a property of AMyTestActor.

greetings

FTC

avatar image Doug E ♦♦ STAFF Mar 12 '15 at 08:21 PM

Hey FTC-

Does this crash still occur for you in the latest engine version (4.7.2)? I'm trying to test the code you posted above, I created a class based on Actor and added your code to the class but I'm receiving compile errors. Did you add your test function to an actor class or another class? Let me know if there's other steps that I'm missing.

avatar image FTC Mar 13 '15 at 09:34 AM

Yes the crash still occurs and I get no compile errors with the latest launcher version. I use an actor and I have not done anything special to it. My test simply iterated through actors of that class and called the function in the level blueprint.

avatar image FTC Mar 13 '15 at 09:39 AM

Here is the callstack

callstack.txt (3.7 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey FTC-

Rather than returning a TWeakObjectPtr you could return UObject* instead. The following segment of code is an example of how you can use a TWeakObjectPtr inside a function and then return the UObject.

 UObject* Function()
 {
      TWeakObjectPtr* Variable;
      return Variable.Get();
 }

Cheers

Doug Wilson

more ▼

answered Mar 13 '15 at 11:49 PM

avatar image FTC Mar 19 '15 at 09:45 PM

Thank you, but I know I can simply return an object pointer, the whole point of it was to not do it. Using TWeakObjectPtr as parameters throws up compile errors as it is obviously not supported, returning them, however, doesn't but it nevertheless seems to be unsupported by blueprints.

avatar image Doug E ♦♦ STAFF Mar 27 '15 at 08:24 PM

Hey FTC-

Anytime a TWeakObjectPtr could be returned, a UObject could be returned instead however I have reported the bug that attempting to return a TWeakObjectPtr does not give any error warning (UE-12214).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question