Skip to content

Commit ac57159

Browse files
authored
ZJIT: Don't attempt to disassemble code when there's a compilation error (rubyGH-16251)
After a compilation error, the write pointer may point into unmapped JIT memory. Passing that address as the end of the disassembly range to capstone causes a segfault when it reads past the boundary of the mapped region.
1 parent 7b3207e commit ac57159

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

zjit/src/backend/lir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ impl Assembler
22022202
});
22032203

22042204
#[cfg(feature = "disasm")]
2205-
if get_option!(dump_disasm) {
2205+
if get_option!(dump_disasm) && ret.is_ok() {
22062206
let end_addr = cb.get_write_ptr();
22072207
let disasm = crate::disasm::disasm_addr_range(cb, start_addr.raw_ptr(cb) as usize, end_addr.raw_ptr(cb) as usize);
22082208
println!("{}", disasm);

0 commit comments

Comments
 (0)