You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was seeing segfaults in libsqlite running one of the tests on rusqlite on the latest nightly. Tracked it down to rust not calling extern "C" functions with variable args correctly.
Given this C function:
voidfoobar(int32_tx, ...) {
va_listap;
va_start(ap, 2);
uint64_ty=va_arg(ap, uint64_t);
uint64_tz=va_arg(ap, uint64_t);
va_end(ap);
printf("called with x = %d and varargs %#lx %#lx\n", x, y, z);
}
where two 64-bit values are expected in the varargs, and this Rust function:
both work correctly on nightly, but given this started causing segfaults in code that was working previously, I wonder if a warning or error could be issued for "you're passing a 0-sized thing to a C function and that's probably not what you want"? (I assume the output I pasted above from nightly is a result of rustc skipping over the 0-size callback and passing only a single parameter to the varargs instead of two.)
The text was updated successfully, but these errors were encountered:
I was seeing segfaults in libsqlite running one of the tests on rusqlite on the latest nightly. Tracked it down to rust not calling extern "C" functions with variable args correctly.
Given this C function:
where two 64-bit values are expected in the varargs, and this Rust function:
Running on
rustc 1.8.0-beta.2 (2879d940a 2016-03-22)
outputsand running on
rustc 1.9.0-nightly (d5a91e695 2016-03-26)
outputs(I uploaded a full cargo project reproducer.)
I assume this is related to #19925, as both workarounds listed there for transmute fix the above problem too; i.e.,
both work correctly on nightly, but given this started causing segfaults in code that was working previously, I wonder if a warning or error could be issued for "you're passing a 0-sized thing to a C function and that's probably not what you want"? (I assume the output I pasted above from nightly is a result of rustc skipping over the 0-size
callback
and passing only a single parameter to the varargs instead of two.)The text was updated successfully, but these errors were encountered: