Exception when calling SetParent of Transform

code tries to inject an intermediate parent object in hierarchy when instantiated and in Awake.
callstack starts from libil2cpp.so but ends in libunity.so,
need to know if we are doing anything wrong here ?
what can cause this issue in unity ?

- a
     - b
     - c

will be transformed to

- a
     - newparent
          - b
          - c

Unity version: 2021.3.13f1
Callstack decoded with symbols from play console for this crash:

Fatal Exception: Tombstone: Version '2021.3.13f1 (9e7d58001ecf)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
Build fingerprint: 'vivo/V2339i/V2339:14/UP1A.231005.007/compiler05132000:user/release-keys'
Revision: '0'
ABI: 'arm'
Timestamp: 2024-06-12 18:51:47+0530
pid: 5515, tid: 16839, name: UnityMain  >>> xxxx.xxxxxx.xxx.xxxxxxx <<<
uid: 10305
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c
Cause: null pointer dereference
    r0  00000000  r1  00994c98  r2  931f3f94  r3  00000000
    r4  00000000  r5  9174f114  r6  954da9bc  r7  954daa48
    r8  8d479860  r9  0000000e  r10 0000000e  r11 00000004
    ip  931f3f80  sp  954da980  lr  90db7b3d  pc  90db8962
#00 pc 0x378962 (UI::CanvasRenderer::OnParentingChanged() at ??:?) libunity.so
#01 pc 0x377b39 (UI::CanvasRenderer::UpdateParentHierarchy() at ??:?) libunity.so
#02 pc 0x378a01 (UI::CanvasRenderer::UpdateParentHierarchyChange(TransformAccess const*, unsigned int) at ??:?) libunity.so
#03 pc 0x19e873 (TransformHierarchyChangeDispatch::smile:ispatchSelfAndAllChildren(TransformAccess, TransformHierarchyChangeDispatch::InterestType) at ??:?) libunity.so
#04 pc 0x1a0f7b (Transform::SetParent(Transform*, Transform::SetParentOption) at ??:?) libunity.so
#05 pc 0x802fd (Transform_CUSTOM_SetParent(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*, unsigned char) at ??:?) libunity.so

For UI related questions, try asking in Unity Engine - Unity Discussions

@Tomas1856 Thank you for quick response.
I understand this should be reported with unity bug-reporter, but we don’t have minimum reproducible steps or isolated unity project which can re-produce this.

This issue is happening on prod for some users, hence wanted to confirm if this is Unity issue or scripting issue.

As suggested I have posted the same in UI related forum.

Your message was moved to the UI forum, so the other one got deleted as it’s a duplication.

It’s impossible to troubleshoot without actual code that reproduces the issue consistently, but I would suggest moving the code that does the parent switching away from Awake and into something later down the lifecycle. Maybe Start is a good candidate. You can see the complete lifecycle here: Unity - Manual: Order of execution for event functions

Otherwise we’d need an actual bug report with steps and preferably a minimal sample project to reproduce and fix it effectively.

1 Like