src_strerror and png_write_chunk_end Development build crash UE 5.4

Hey all, I’m getting this crash in development builds. I don’t really understand it, or what is wrong with my game. For context, my game has a lot of building elements and possessing many different pawns. Not sure if that raises any questions.

For more context, I have been dealing with seemingly random crashes in my game for the past week when I play the game longer than about 5 minutes. The errors I get seem to be differ each time, but they always seem to point to src_strerror and png_write_chunk_end. Lastly, when I run gc.CollectGarbageEveryFrame 1, it was stable past the expected time of crash. The moment I set the CVar to 0, the game crashed.

Any help or pointing me in the right direction would be appreciated :slight_smile:

FILE_IN_CAB:  UEMinidump.dmp

CONTEXT:  (.ecxr)
rax=00007ffc024747b1 rbx=00007ff7d0c2f989 rcx=0000000000000020
rdx=0000013798690e40 rsi=0000000000000000 rdi=0000002d08efcce0
rip=00007ffbffb1b699 rsp=0000002d08efc2a0 rbp=00007ff7dc8db218
 r8=00007ff7cd2f3e4d  r9=000001379e131bd0 r10=0000000000000000
r11=0000000000000000 r12=00000137eb755450 r13=0000000000000000
r14=00007ff7dc8db218 r15=0000000000004000
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000206
KERNELBASE!RaiseException+0x69:
00007ffb`ffb1b699 0f1f440000      nop     dword ptr [rax+rax]
Resetting default scope

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffbffb1b699 (KERNELBASE!RaiseException+0x0000000000000069)
   ExceptionCode: 00004000
  ExceptionFlags: 00000000
NumberParameters: 1
   Parameter[0]: 0000002d08efc3c8

PROCESS_NAME:  TrainGame.exe

ERROR_CODE: (NTSTATUS) 0x4000 - <Unable to get error code text>

EXCEPTION_CODE_STR:  4000

EXCEPTION_PARAMETER1:  0000002d08efc3c8

STACK_TEXT:  
0000002d`08efc2a0 00007ff7`cd4e8a4c     : 00000000`00000000 00007ff7`d9410230 0000002d`08efc460 00000000`00000000 : KERNELBASE!RaiseException+0x69
0000002d`08efc380 00007ff7`cd32dc7f     : 00000000`00000000 00007ffb`00000000 0000002d`08efcce0 0000002d`08efcce0 : TrainGame!png_write_chunk_end+0xad182c
0000002d`08efcca0 00007ff7`cd25228d     : 00000202`002b002b 00007ff7`d93be7f0 00007ff7`d9b16f08 00007ff7`d9b16070 : TrainGame!png_write_chunk_end+0x916a5f
0000002d`08efd140 00007ff7`cd25391c     : 00007ff7`dc57f4f8 00000000`5f33a001 0000002d`00000000 00007ff7`00006084 : TrainGame!png_write_chunk_end+0x83b06d
0000002d`08eff1c0 00007ff7`d0c2f989     : 00000000`000005b3 0000002d`08eff330 00000138`00000491 00007ff7`d934a3dc : TrainGame!png_write_chunk_end+0x83c6fc
0000002d`08eff230 00007ff7`d0c39a62     : 00000137`dc8f9398 00000137`98651750 00000137`d68016b0 00000138`0e371da8 : TrainGame!src_strerror+0xe29649
0000002d`08eff620 00007ff7`ccf3c2e8     : 00000137`98651750 00000137`98651790 00000000`000000ff 00000000`4c3d6400 : TrainGame!src_strerror+0xe33722
0000002d`08eff720 00007ff7`ccf43bf3     : 00000000`ffffffff 00000000`00000028 0000002d`08eff7e0 00007ff7`cd037360 : TrainGame!png_write_chunk_end+0x5250c8
0000002d`08eff780 00007ff7`ccf5159e     : 00000137`dc8f9348 0000002d`08eff8d0 00007ff7`dc732900 00000137`dc8f9348 : TrainGame!png_write_chunk_end+0x52c9d3
0000002d`08eff7b0 00007ff7`ccf5131b     : 00000000`00000000 00000137`dc8f9348 00000137`985b1580 00000000`00000000 : TrainGame!png_write_chunk_end+0x53a37e
0000002d`08eff830 00007ff7`ccf77135     : 00000137`9cfe0000 00000000`00000000 00000137`dc8f9348 00000137`9cfe0000 : TrainGame!png_write_chunk_end+0x53a0fb
0000002d`08eff870 00007ff7`ccf41580     : 00000000`00000001 00000137`9b8bc740 00000137`9cfe0000 00007ff7`000002cf : TrainGame!png_write_chunk_end+0x55ff15
0000002d`08eff910 00007ff7`cd137ee3     : 00000137`9a1d1000 00000000`00000000 00000000`00000000 00000000`00000000 : TrainGame!png_write_chunk_end+0x52a360
0000002d`08eff950 00007ff7`cd55f608     : 00000137`9a1d1000 00000000`00000000 00000000`00000000 00000000`00000000 : TrainGame!png_write_chunk_end+0x720cc3
0000002d`08eff980 00007ff7`cd553157     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : TrainGame!png_write_chunk_end+0xb483e8
0000002d`08eff9b0 00007ffc`00957374     : 00000137`9a1d1000 00000000`00000000 00000000`00000000 00000000`00000000 : TrainGame!png_write_chunk_end+0xb3bf37
0000002d`08eff9f0 00007ffc`0249cc91     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14
0000002d`08effa20 00000000`00000000     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21

Here are the logs before the crash

[2025.01.21-07.34.47:748][753]LogViewport: Display: Viewport MouseLockMode Changed, DoNotLock -> LockOnCapture
[2025.01.21-07.34.47:748][753]LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently
[2025.01.21-07.34.47:752][753]LogStreaming: Display: FlushAsyncLoading(100): 1 QueuedPackages, 0 AsyncPackages
[2025.01.21-07.34.48:201][786]LogStreaming: Display: FlushAsyncLoading(101): 1 QueuedPackages, 0 AsyncPackages
[2025.01.21-07.35.02:179][160]LogStreaming: Display: FlushAsyncLoading(102): 1 QueuedPackages, 0 AsyncPackages
[2025.01.21-07.35.02:183][160]LogMaterial: Error: Loading a material resource None with an invalid ShaderMap!
[2025.01.21-07.35.02:183][160]LogMaterial: Error: Loading a material resource None with an invalid ShaderMap!
[2025.01.21-07.35.02:184][160]LogMaterial: Error: Tried to access an uncooked shader map ID in a cooked application
[2025.01.21-07.35.02:184][160]LogMaterial: Warning: Invalid shader map ID caching shaders for 'UITransitionMaskSketch', will use default material.
[2025.01.21-07.35.02:184][160]LogMaterial: Can't compile UITransitionMaskSketch with cooked content, will use default material instead
[2025.01.21-07.35.02:184][160]LogMaterial: Warning: [AssetLog] D:\Desktop\Train Game\Windows\TrainGame\Content\_Assets\Materials\UI\UITransitionMaskSketch: Failed to compile Material for platform PCD3D_SM6, Default Material will be used in game.

[2025.01.21-07.35.05:209][437]LogOutputDevice: Warning: 

Script Stack (0 frames) :

[2025.01.21-07.35.05:218][437]LogWindows: Error: appError called: Assertion failed: RayTracingInstance.NumTransforms == InstanceBatch.Cursor [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Renderer\Private\RayTracing\RayTracing.cpp] [Line: 1206] 


[2025.01.21-07.35.05:218][437]LogWindows: Windows GetLastError: The operation completed successfully. (0)

Wanted to give an update. I am still stuck on this and getting pretty desperate for help. I have spent all week wrestling with this and no progress made. I’ve collected more logs and crashes, but the core issue seems to be unknown. It’s always some worker thread that crashes and leads to a “Fatal Error!” message.

What I’ve done:

  • Reviewed my code for memory leaks. I found some small errors and fixed those, but it did not stop the crashes.
  • Address almost every warning I could see in the console. Every warning was some minor offense, but I fixed as many as I could. There are still a couple lingering warnings, but nothing major.
  • Ensured all blueprints unbind events when they are supposed to.
  • Generated Debug builds for better stack traces.

Still nothing. I have to play my game between 5-8 minutes usually to get this crash to proc. I have no idea why it takes so long to manifest and why it’s so inconsistent. Sometimes I have to wait about 10 minutes for it to crash.

I’ll add one small correction from my last post here. Setting gc.CollectGarbageEveryFrame 1 does not seem to actually stop crashes. I was able to get a crash with it turned on. Has anyone noticed potential instability with builds in 5.4? I tried updating to 5.5, but I can’t get Rider to rebuild RiderLink and thus I can’t compile my code for 5.5. Had to create another post for that.

At long last, I’ve gotten to the bottom of this. To be frank, I’m still not 100% sure why the crash was happening, but I’ll explain it as best I can. Hopefully, this will be useful to at least one other person out in the world.

It all came down to my building actors (BP_Mechanism) not handling destruction properly. But, I first need to explain how my moving platforms are handled.

In my game, I have a C++ Actor Component called MovingPlatform. This component handles tweening an actor around for basic moving platform behavior and has lots of customization. More importantly, it sets the component velocity for each component that is attached to itself, every tick. This is to make sure that as a character jumps off the platform, they receive the velocity that they are supposed to.

MovingPlatform has a TArray<USceneComponent*> that stores the scene components it is managing their velocities. At runtime, other actors can add their components through:

void UMovingPlatform::AddVelocityAffectedComponent(USceneComponent* Component)
void UMovingPlatform::RemoveVelocityAffectedComponent(USceneComponent* Component)

However, in my BP_Mechanism, RemoveVelocityAffectedComponent() was not always being called. A Detach bp node was used before the Remove Component node. This meant that in the TArray a USceneComponent pointer would go stale because of gc. Eventually, that would lead to a crash.

So to fix this, I first changed when the RemoveVelocityAffectedComponent() node was called so that it would always execute before DestroyActor() was called. And more importantly, I changed the TArray to TArray<TWeakObjectPtr<USceneComponent>> so that if the pointer went stale, it would not lead to crashes. There are also .IsValid() checks where relevant and a cleanup function if a pointer became invalid for some reason.

All in all, it seemed to be a basic mishandling of pointers. The reason that this was so challenging was that at no point did any crash stack trace I received point to either a Mechanism or a MovingPlatform. In fact, the crashes were often never even through the game thread. It would be some worker thread that would crash. MovingPlatform does use latent actions, but the component TArray was never used outside of Tick. Maybe someone with more experience could explain that lol.

TL;DR if you are receiving this crash in your project, you are likely not managing your pointers in some place you would not expect.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.