From 3dc8e7a5bf5e86301e43cc77183539014c805bbf Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 11 Apr 2024 00:31:33 +0000 Subject: [PATCH] Fix comparison base for line table compression 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. --- src/ircode.c | 1 - test/compiler/ssair.jl | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ircode.c b/src/ircode.c index 196f9f7b413ad..2e16d1b5b2420 100644 --- a/src/ircode.c +++ b/src/ircode.c @@ -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; diff --git a/test/compiler/ssair.jl b/test/compiler/ssair.jl index 9d5f7b617080d..9ff4d3d8a4220 100644 --- a/test/compiler/ssair.jl +++ b/test/compiler/ssair.jl @@ -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