Assert in exception.c++ triggering only in ASAN

26 views
Skip to first unread message

Vitali Lovich

unread,
Oct 12, 2020, 5:35:02 PM10/12/20
to Cap'n Proto
I'm seeing this assert trigger in exception.c++ when run on ASAN on our (admittedly old) Linux boxes:

  KJ_ASSERT(offset < 65536 && offset > -65536,
            "ExceptionCallback must be allocated on the stack.");

The value of offset is 1048864. Is this code perhaps relying on some construct that's not reliable under ASAN? I would have expected ASAN to warn about that but it doesn't. Just the exception triggers.

Unfortunately it's a bit hard to run this under a debugger or I would have delved far more on my own (& maybe disassemble things). Any insights would be appreciated.

Thanks,
Vitali

Kenton Varda

unread,
Oct 18, 2020, 4:53:02 PM10/18/20
to Vitali Lovich, Cap'n Proto
I guess this means that under ASAN, the stack is not allocated in the traditional way. For some reason there's a 1MB offset between where the ExceptionCallback was allocated and where a local variable inside its constructor was allocated.

The check there is pretty hacky and probably technically UB. It's meant to detect and warn about bad usage. Assuming the ExceptionCallback is, in fact, being allocated on the stack, then the exception is bogus. I suppose we may need to #ifdef it out when ASAN is active, or find some other way to verify that the object is stack-allocated...

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/de1aaa9b-c798-467d-b1d2-11ac9ae42880n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages