janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.56k stars 229 forks source link

ffi/struct call leads to janet process termination #1512

Closed sogaiu closed 1 month ago

sogaiu commented 1 month ago

According to the docs:

The void type can only be used as a return value

so, it makes sense that (ffi/struct :void) shouldn't work.

Currently though, the running janet process terminates:

$ janet
Janet 1.37.0-dev-282f2671 linux/x64/gcc - '(doc)' for help
repl:1:> (ffi/struct :void)
Floating point exception
$ echo $?
136

Is it practical to error without process termination instead?

bakpakin commented 1 month ago

Yup, that is an issue - root cause is a division by zero when we are calculating size and alignment. Just pushed a fix, I think this reveals a bit of a hole in our FFI testing.