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

CRASH disassembling regdeps ISA with non-DR syntax requested #6942

Open
derekbruening opened this issue Aug 27, 2024 · 3 comments
Open

CRASH disassembling regdeps ISA with non-DR syntax requested #6942

derekbruening opened this issue Aug 27, 2024 · 3 comments
Assignees

Comments

@derekbruening
Copy link
Contributor

I hit this in PR #6941 where the syntax got set to DR_DISASM_ATT and then the view test crashed on its regdeps case. This crash will happen anytime regdeps is disassembled with a syntax other than DR_DISASM_DR:

Program received signal SIGSEGV, Segmentation fault.
0x00005555556cebbe in get_next_instr_info (info=0x0) at core/ir/x86/decode.c:2779
2779        return (const instr_info_t *)(info->code);
(gdb) bt
#0  0x00005555556cebbe in get_next_instr_info (info=0x0) at core/ir/x86/decode.c:2779
#1  0x00005555556cecf7 in get_encoding_info (instr=0x7fffffffc3b0) at core/ir/encode_shared.c:106
#2  0x00005555556de721 in instr_disassemble_opnds_noimplicit (buf=0x7fffffffc520 " 00010011 00060906 move [8byte]       ", bufsz=196, sofar=0x7fffffffc4a8, 
    dcontext=0xffffffffffffffff, instr=0x7fffffffc3b0) at core/ir/disassemble_shared.c:1006
#3  0x00005555556dfbb4 in internal_instr_disassemble (buf=0x7fffffffc520 " 00010011 00060906 move [8byte]       ", bufsz=196, sofar=0x7fffffffc4a8, 
    dcontext=0xffffffffffffffff, instr=0x7fffffffc3b0) at core/ir/disassemble_shared.c:1300
#4  0x00005555556de278 in internal_disassemble (buf=0x7fffffffc520 " 00010011 00060906 move [8byte]       ", bufsz=196, sofar=0x7fffffffc4a8, dcontext=0xffffffffffffffff, 
    pc=0x7fffffffca68 "\021", orig_pc=0x7f6fdd3ec360 <error: Cannot access memory at address 0x7f6fdd3ec360>, with_pc=false, with_bytes=true, 
    extra_bytes_prefix=0x55555573adf4 "") at core/ir/disassemble_shared.c:862
#5  0x00005555556de684 in disassemble_to_buffer (drcontext=0xffffffffffffffff, pc=0x7fffffffca68 "\021", 
    orig_pc=0x7f6fdd3ec360 <error: Cannot access memory at address 0x7f6fdd3ec360>, show_pc=false, show_bytes=true, 
    buf=0x7fffffffc520 " 00010011 00060906 move [8byte]       ", bufsz=196, printed=0x0) at core/ir/disassemble_shared.c:980
@derekbruening
Copy link
Contributor Author

I'm solving this in the drmemtrace view tool by forcing DR_DISASM_DR; not 100% sure what the larger fix inside DR core should be. Probably it should not accept other syntax requests.

derekbruening added a commit that referenced this issue Aug 27, 2024
style for REGDEPS traces.

This change actually sets the disasm syntax to AT&T by default if no
module path is passed in; which is what it is supposed to do: but it
was not doing that and this breaks 3 tests comparing DR-style output.
We put in a quick fix to request DR style for those tests.

Issue: #6942
derekbruening added a commit that referenced this issue Aug 27, 2024
The view tool was blindly loading binaries even for traces that have
encodings.  This leads to fatal errors when binaries have changed, even
when the change has no impact on viewing a trace.  We fix that here by
reading the filtype at init time.

Work around the #6942 crash by always setting the disasm syntax to DR
style for REGDEPS traces.
    
This change actually sets the disasm syntax to AT&T by default if no
module path is passed in; which is what it is supposed to do: but it was not
doing that and this breaks 3 tests comparing DR-style output. We put in a
quick fix to request DR style for those tests.

Tested locally where the view tool asserts without this fix.

Issue: #6940, #6942
Fixes #6940
@edeiana
Copy link
Contributor

edeiana commented Aug 27, 2024

Ah, interesting.
I remember testing (manually, probably should have written tests) the view tool/disassembly with all the syntax flags.
Thank you for fixing it!

@derekbruening
Copy link
Contributor Author

Thank you for fixing it!

Just to be clear I only worked around the crash in the drmemtrace view tool. Any other use of the DR disassembly code on the regdeps ISA would presumably hit the same crash, so we should have some kind of DR core fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants