Odin
Odin copied to clipboard
Memory corruption on Linux when csv.Reader is in a global variable
Context
The latest odin:
Odin: dev-2022-10:662ed4a6
OS: Manjaro Linux, Linux 5.10.148-1-MANJARO
CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
RAM: 15953 MiB
and the following program:
package main
import "core:fmt"
import "core:encoding/csv"
app: csv.Reader
main :: proc() {
fmt.println(app)
}
Expected Behavior
The program should correctly print a zero'd csv.Reader, the same as it does when the app: csv.Reader variable is declared wtihin main.
Current Behavior
On my Linux machine, random output such as:
$ ./o220.bin |od -c
pppppppppppppppppppppppppppppp0000000 p p p p p p p p p p p p p p p p
0000020
from such syscalls as:
$ strace -ewrite ./o220.bin 2>&1|head -5
write(6, "p\353A\0\0\0", 6) = -1 EBADF (Bad file descriptor)
write(1, "p\353A\0\0\0\0\0\0\0\0\0\0\0\0\0@qC\0\0\0\0\0 \207\207\357/\177\0\0"..., 140728478333911) = -1 EFAULT (Bad address)
write(5, "p\353A\0\0", 5) = -1 EBADF (Bad file descriptor)
write(3, "p\353A", 3) = -1 EBADF (Bad file descriptor)
write(1, "p\353A\0\0\0\0\0\0\0\0\0\0\0\0\0@qC\0\0\0\0\0 \207\207\357/\177\0\0"..., 140728478332615) = -1 EFAULT (Bad address)
On Windows, this is reported to not be an error. On another Linux machine, the reported behavior was a segfault from app.reader.comma = ',' after the print.