Skip to content

Commit 68b3bb2

Browse files
committed
tests: [diag] dump JIT'd vmi type_info (_ZTI1D) bytes to pin the corrupt field
1 parent 2a4c559 commit 68b3bb2

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/jitmin.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ jobs:
109109
SKIP_INIT=1 ./build/jitmin.exe "$ORC" "$n.ll" entry "$LIBCXXA"
110110
echo " >>> $n skipinit exit=$?"
111111
echo "::endgroup::"
112+
# Dump the JIT'd vmi type_info bytes for the crashing MI cast case.
113+
if [ "$n" = "c10_mi_cast_only" ]; then
114+
echo "::group::DUMP $n _ZTI1D"
115+
SKIP_INIT=1 DUMP_TI=_ZTI1D ./build/jitmin.exe "$ORC" "$n.ll" entry "$LIBCXXA" 2>&1 | grep -aE "\[ti\]"
116+
echo "::endgroup::"
117+
fi
112118
# Native-TLS variant: does JITLink handle COFF .tls without emutls?
113119
case "$n" in c03*|c04*)
114120
"$CXX" -target x86_64-w64-windows-gnu -stdlib=libc++ -fno-emulated-tls \

tests/jit-min/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,33 @@ int main(int argc, char** argv)
197197
if(!sym)
198198
fail("lookup", sym.takeError());
199199

200+
// DIAG: dump a JIT'd type_info object's raw bytes to find which field is
201+
// mis-materialized (vtable ptr / name / flags / base array). In-process JIT, so
202+
// the executor address is directly readable here.
203+
if(const char* tiName = std::getenv("DUMP_TI"))
204+
{
205+
if(auto a = (*jit)->lookup(tiName))
206+
{
207+
const uint64_t* ti = (const uint64_t*)a->getValue();
208+
errs() << "[ti] " << tiName << " @" << (void*)ti << "\n";
209+
for(int i = 0; i < 7; i++)
210+
errs() << "[ti] +" << (i * 8) << " = " << (void*)ti[i] << "\n";
211+
errs().flush();
212+
// The vtable ptr (ti[0]) should point ~16 bytes into a cxxabi vtable.
213+
// Read a couple of slots around it (may itself fault if ti[0] is garbage,
214+
// but the bytes above are already flushed).
215+
const uint64_t* vt = (const uint64_t*)ti[0];
216+
errs() << "[ti] *vtable[-2..1] = " << (void*)vt[-2] << " " << (void*)vt[-1]
217+
<< " " << (void*)vt[0] << " " << (void*)vt[1] << "\n";
218+
errs().flush();
219+
}
220+
else
221+
{
222+
consumeError(a.takeError());
223+
errs() << "[ti] " << tiName << " NOTFOUND\n";
224+
}
225+
}
226+
200227
if(std::getenv("SKIP_INIT"))
201228
{
202229
step("SKIP_INIT set -- not calling initialize()");

0 commit comments

Comments
 (0)