Odin
Odin copied to clipboard
linalg.transpose from column to row matrix causes segfault
Context
Starting from #3686 and potentially related to #2641, I've found another segfault when converting to row_major matrices:
package transpose_crash_repro
import "core:fmt"
import "core:math/linalg"
main :: proc() {
a := (# row_major matrix[4, 4]f32)(1)
b1: # column_major matrix[4, 4]f32 = linalg.transpose(a)
b2: # row_major matrix[4, 4]f32 = linalg.transpose(a)
fmt.println("row -> {row, column} ok")
c := (# column_major matrix[4, 4]f32)(1)
d1: # column_major matrix[4, 4]f32 = linalg.transpose(c)
fmt.println("column -> column ok")
d2: # row_major matrix[4, 4]f32 = linalg.transpose(c)
fmt.println("column -> row broken")
}
Fails on the last transpose but none before it.
$ odin run test.odin -file
row -> {row, column} ok
column -> column ok
Segmentation fault (core dumped)
Failure Information (for bugs)
odin version dev-2025-08-nightly
Still get hit by this in dev 2025 11.
I reverted my fix because it was an immediate fix, but wasn't doing the right thing. To be clear this should behave as a cast, so these lines should do the same thing:
a := cast(#row_major matrix[4, 4]f32)src
b: #row_major matrix[4, 4]f32 = linalg.transpose(src)
I did add a panic, so it's a compile time error instead of a runtime error now.