I went down the the call chain and
$ss13swift_release6objectyBp_tF
$ss13swift_release6objectyBp_tF:
08000394: push {r4, r7, lr}
08000396: add r7, sp, #4
08000398: str.w r10, [sp, #-4]!
0800039c: cbz r0, 0x80003c8 <$ss13swift_release6objectyBp_tF+52>
0800039e: ldr r1, [r0, #4]
080003a0: adds r1, #1
080003a2: beq.n 0x80003c8 <$ss13swift_release6objectyBp_tF+52>
080003a4: adds r2, r0, #4
080003a6: dmb sy
080003aa: ldrex r3, [r2]
080003ae: subs r1, r3, #1
080003b0: strex r4, r1, [r2]
080003b4: cmp r4, #0
080003b6: bne.n 0x80003aa <$ss13swift_release6objectyBp_tF+22>
080003b8: cmp r1, r3
080003ba: dmb sy
080003be: bvs.n 0x80003ce <$ss13swift_release6objectyBp_tF+58>
080003c0: lsls r1, r1, #1
080003c2: bne.n 0x80003c8 <$ss13swift_release6objectyBp_tF+52>
080003c4: bl 0x8000540 <OUTLINED_FUNCTION_1>
080003c8: ldr.w r10, [sp], #4
080003cc: pop {r4, r7, pc}
080003ce: udf #254 @ 0xfe
calls into
OUTLINED_FUNCTION_1
OUTLINED_FUNCTION_1:
08000540: mov.w r1, #4294967295 @ 0xffffffff
08000544: mov r10, r0
08000546: str r1, [r0, #4]
08000548: ldr r1, [r0, #0]
0800054a: ldr r1, [r1, #4]
0800054c: bx r1
which loads an address of and calls into this one
$s4game16startSwiftEngineyyF13CDontMangleMeL_CfD
$s4game16startSwiftEngineyyF13CDontMangleMeL_CfD:
08000241: mov r0, r10
08000243: b.w 0x80002d4 <$ss26swift_deallocClassInstance6object13allocatedSize0F9AlignMaskyBp_S2itF>
and this
$ss26swift_deallocClassInstance6object13allocatedSize0F9AlignMaskyBp_S2itF:
080002d5: ldr r1, [r0, #4]
080002d7: cmp r1, #0
080002d9: bmi.n 0x80002de <$ss26swift_deallocClassInstance6object13allocatedSize0F9AlignMaskyBp_S2itF+10>
080002db: b.w 0x80016dc <free>
080002df: bx lr
The last one compares refcount with 0
and returns without calling <free>
Looks like execution flow sets the RC to -1 and only then calls the actual deallocation routine $ss26swift_deallocClassInstance6object13allocatedSize0F9AlignMaskyBp_S2itF
which in turn does nothing because it compares refcount (-1
) with (0
)
So OUTLINED_FUNCTION_1
makes object immortal for some reason, I guess there's nothing I can do in my code to fix it right ?