Fix JIT assert resolving to C runtime assert after jitshared introduction#124977
Fix JIT assert resolving to C runtime assert after jitshared introduction#124977
assert resolving to C runtime assert after jitshared introduction#124977Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
…m jitshared headers Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
assert resolving to C runtime assert after jitshared introduction
|
@copilot, the interpreter is now missing a definition for assert. Could you fix that by moving the jit assert API into jitshared? |
… interpreter Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
Done in commit 40fb666. Created |
After PR #123830 introduced the
jitshared/directory,assertin JIT (and interpreter) code was silently falling through to the C runtime'sassert, causing dialog popups on assertion failures instead of usingassertAbort.Root Cause
The JIT sets up
assert → assertAbortinhost.h, whichalloc.hincludes before the jitshared headers. However, three files injitshared/included<assert.h>/<cassert>directly, which unconditionally redefinedassertback to the C runtime version — clobbering the JIT's custom handler:arenaallocator.h—#include <assert.h>compallocator.h—#include <assert.h>histogram.cpp—#include <cassert>The interpreter had a related issue:
histogram.cpp(compiled as part of the interpreter without a PCH) had noassertdefinition at all after removing#include <cassert>, since the interpreter doesn't use a precompiled header to supply it.Changes
jitshared/arenaallocator.h,jitshared/compallocator.h: Remove#include <assert.h>. The correctassertis now provided byjitassert.hviajitshared.h.jitshared/histogram.cpp: Remove#include <cassert>—jitassert.h(included viahistogram.h) now supplies the correct definition.jitshared/jitassert.h(new): Shared header that declaresassertAbort(withANALYZER_NORETURN) and definesassertto use it in DEBUG builds, or((void)0)in release builds. This is the single source of truth for the assert API shared between JIT and interpreter.jitshared/jitshared.h: Includejitassert.hso all jitshared code that goes throughjitshared.hautomatically gets the correctassert.jitshared/histogram.h: Includejitassert.hdirectly, sohistogram.cppin the interpreter build (which doesn't go throughjitshared.h) also gets the correctassert.interpreter/interpreter.h: Reverted to original include order (compiler.hbefore theassertAbortblock) — jitshared code now correctly getsassertfromjitassert.hvia the jitshared include chain, making the ordering no longer relevant.Original prompt
assertresolves to C runtime assert #124954💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.