clay
clay copied to clipboard
[Bug] Debug View: `currentElementData->debugData` is `NULL`
I currently have a fairly complex setup where I use the CLAY_IDI() macro with random ints as keys.
It all works flawlessly, however, when calling on a more complex tree Clay_SetDebugViewEnabled(true), I get a segfault:
AddressSanitizer:DEADLYSIGNAL
=================================================================
==86556==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x00010459e1dc bp 0x00016bca7690 sp 0x00016bca2c40 T0)
==86556==The signal is caused by a READ memory access.
==86556==Hint: address points to the zero page.
#0 0x10459e1dc in Clay__RenderDebugLayoutElementsList clay.h:3831
#1 0x1045ab55c in Clay__RenderDebugView clay.h:4052
#2 0x1045c6b10 in Clay_EndLayout clay.h:4975
#3 0x10454305c in GUI_RenderCommands draw.c:658
#4 0x1045d64bc in idleCallback main.c:38
#5 0x10421a708 in uv__run_idle+0x84 (djs-aarch64-macos:arm64+0x1000ce708)
#6 0x104213fa8 in uv_run+0x120 (djs-aarch64-macos:arm64+0x1000c7fa8)
#7 0x1043a9c48 in TJS_RunWithIdleCallback vm.c:486
#8 0x1045d6ee8 in main main.c:87
#9 0x190d920dc (<unknown module>)
==86556==Register values:
x[0] = 0x0000000000000000 x[1] = 0x0000000000000001 x[2] = 0x000000000000000a x[3] = 0x000000016bca1790
x[4] = 0xfffffffffffffef0 x[5] = 0x0000000000000020 x[6] = 0x0000000000000000 x[7] = 0x000000016bca76a0
x[8] = 0x0000000000000000 x[9] = 0x0000000000000001 x[10] = 0x000000016bca2980 x[11] = 0x000000016bca2990
x[12] = 0x000000016bca2988 x[13] = 0x000000016bca2980 x[14] = 0x0000f2f2f2f20000 x[15] = 0x0000000000000000
x[16] = 0x000000019114b1a0 x[17] = 0x00000001050d85d0 x[18] = 0x0000000000000000 x[19] = 0x000000016bca5b60
x[20] = 0x000000010c020268 x[21] = 0x000000016bcb2810 x[22] = 0x0000000000000000 x[23] = 0x000000010c020068
x[24] = 0x000000010c020268 x[25] = 0x00000000fffffffd x[26] = 0x0000000000000005 x[27] = 0x000000016bcb2850
x[28] = 0x00000001045e76e8 fp = 0x000000016bca7690 lr = 0x000000010459e124 sp = 0x000000016bca2c40
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV clay.h:3831 in Clay__RenderDebugLayoutElementsList
==86556==ABORTING
make: *** [run] Abort trap: 6
I could trace the issue back to debugData being initialized with the default struct (all 0).
I've tried to do some monkey patches but that just spiraled out of control because the debug view assumes the debugData to always be set.