Skip to content

Commit

Permalink
Fix comparison base for line table compression
Browse files Browse the repository at this point in the history
I'm not entirely sure what the original intent of this statement
was, but the effect ends up being that some codeloc entries end
up negative in the compressed representation, but the code always
assumes unsigned integers, so things roundtripped badly, leading
to badly corrupted stack traces. Fixes #54031.
  • Loading branch information
Keno committed Apr 11, 2024
1 parent 97ac3ec commit 3dc8e7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/ircode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,6 @@ JL_DLLEXPORT jl_string_t *jl_compress_codelocs(int32_t firstline, jl_value_t *co
#undef SETMIN
#undef SETMAX
}
min.line = min.to = min.pc = firstline <= 0 ? INT32_MAX : firstline;
int32_t header[3];
header[0] = min.line > max.line ? 0 : min.line;
header[1] = min.line > max.line ? 0 : max.line - min.line;
Expand Down
7 changes: 7 additions & 0 deletions test/compiler/ssair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -825,3 +825,10 @@ end
@test_throws ErrorException f_must_throw_phinode_edge()
global global_error_switch = false
@test f_must_throw_phinode_edge() == 1

# Test roundtrip of debuginfo compression
let cl = Int32[32, 1, 1, 1000, 240, 230]
str = ccall(:jl_compress_codelocs, Any, (Int32, Any, Int), 378, cl, 2)::String;
cl2 = ccall(:jl_uncompress_codelocs, Any, (Any, Int), str, 2)
@test cl == cl2
end

0 comments on commit 3dc8e7a

Please sign in to comment.