Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASSERT "internal isa mode error" on ubuntu22 in many tests #7320

Closed
derekbruening opened this issue Mar 4, 2025 · 0 comments · Fixed by #7321
Closed

ASSERT "internal isa mode error" on ubuntu22 in many tests #7320

derekbruening opened this issue Mar 4, 2025 · 0 comments · Fixed by #7321

Comments

@derekbruening
Copy link
Contributor

For #7270 we need to move our tests to Ubuntu22.
Many fail there with this assert, here in client.tls:

in foo_t::foo_t
<curiosity: rex.w on OPSZ_6_irex10_short4!>
<Application /home/derek/dr/git/build_x64_dbg_tests/suite/tests/bin/client.tls (169991) DynamoRIO usage error : internal isa mode error>
<Usage error: internal isa mode error (/home/derek/dr/git/src/core/ir/decode_shared.c, line 261)

The assert is here:

#0  report_dynamorio_problem (dcontext=0x0, dumpcore_flag=16, exception_addr=0x0, report_ebp=0x0, fmt=0x7ffff7d71e57 "Usage error: %s (%s, line %d)")
    at /home/derek/dr/git/src/core/utils.c:2124
#1  0x00007ffff7aee10b in external_error (file=0x7ffff7dad588 "/home/derek/dr/git/src/core/ir/decode_shared.c", line=261, msg=0x7ffff7dad5bd "internal isa mode error")
    at /home/derek/dr/git/src/core/utils.c:201
#2  0x00007ffff7c5ff9e in dr_set_isa_mode (drcontext=0x0, new_mode=DR_ISA_AMD64, old_mode_out=0x7ffdb37e8914) at /home/derek/dr/git/src/core/ir/decode_shared.c:261
#3  0x00007ffff7c60157 in set_x86_mode (drcontext=0x0, x86=false) at /home/derek/dr/git/src/core/ir/x86/decode.c:150
#4  0x00007ffff7c639b4 in read_instruction (pc=0x7ffff7297544 "\213W\020\270\026", orig_pc=0x7ffff7297540 "\363\017\036\372\213W\020\270\026", ret_info=0x7ffdb37e8c58,
    di=0x7ffdb37e8bd0, just_opcode=false, report_invalid=true) at /home/derek/dr/git/src/core/ir/x86/decode.c:1328
#5  0x00007ffff7c67501 in decode_common (dcontext=0xffffffffffffffff, pc=0x7ffff7297540 "\363\017\036\372\213W\020\270\026", orig_pc=0x7ffff7297540 "\363\017\036\372\213W\020\270\026",
    instr=0x7ffdb37e8cf0) at /home/derek/dr/git/src/core/ir/x86/decode.c:2619
#6  0x00007ffff7c68052 in decode (drcontext=0xffffffffffffffff, pc=0x7ffff7297540 "\363\017\036\372\213W\020\270\026", instr=0x7ffdb37e8cf0)
    at /home/derek/dr/git/src/core/ir/x86/decode.c:2782
#7  0x00007ffff7d25610 in privload_set_pthread_tls_fields (mod=0x7ffdb36e9478, priv_tls_base=0x7ffdb37f0000 "") at /home/derek/dr/git/src/core/unix/loader_linux.c:321
#8  0x00007ffff7d25f50 in privload_copy_tls_block (mod=0x7ffdb36e9478, priv_tls_base=0x7ffdb37f0000 "", mod_idx=0) at /home/derek/dr/git/src/core/unix/loader_linux.c:413
#9  0x00007ffff7d2637e in privload_tls_init (app_tp=0x7ffff7000640) at /home/derek/dr/git/src/core/unix/loader_linux.c:509
#10 0x00007ffff7ce6b1c in os_tls_app_seg_init (os_tls=0x7ffdb37ec000, segment=0x7ffdb37ec000) at /home/derek/dr/git/src/core/unix/os.c:2296
#11 0x00007ffff7ce6ec0 in os_tls_init () at /home/derek/dr/git/src/core/unix/os.c:2362
#12 0x00007ffff7a63a94 in dynamo_thread_init (dstack_in=0x7ffdb37ea000 "", mc=0x7ffdb37e8f80, os_data=0x7ffdb37e9880, client_thread=false) at /home/derek/dr/git/src/core/dynamo.c:2302
#13 0x00007ffff7cc9a56 in new_thread_setup (mc=0x7ffdb37e8f80) at /home/derek/dr/git/src/core/arch/x86_code.c:305

That's the #6611 pthread init issue.
I put in the TLS init code right before dcontext is in the thread slot.
It apparently is the only post-global-init-pre-thread-init
decode done anywhere.
It does use GLOBAL_DCONTEXT but the read_instruction call loses that. So I
will either pass in dcontext to read_instruction which seems cleaner but
adds work on the decode path that's not needed for release build...or relax
the assert.

@derekbruening derekbruening self-assigned this Mar 4, 2025
derekbruening added a commit that referenced this issue Mar 4, 2025
Solves an isa mode assert by propagating the dcontext through
read_instruction() for x86 decodes, and keeping GLOBAL_DCONTEXT when
passed into dr_set_isa_mode().

The assert was triggered by a decode after DR global init but before
the thread has its dcontext set up.  The passed-in dcontext turned
from GLOBAL_DCONTEXT to NULL due to no propagation of dcontext through
read_instruction().

Tested on an Ubuntu22 machine where client.tls and other tests hit the
assert without the fix and pass with the fix.

Issue: #7270, #7320
Fixes #7320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant