argonautica
argonautica copied to clipboard
EXC_BAD_ACCESS / stack_not_16_byte_aligned_error with "simd" enabled on macOS 10.15
Hi! I'm not very experienced with all this lower-level stuff (been writing GC'd code in Node.js and OCaml for, like, ten years, and I think I've forgotten everything I ever knew about C 🤣), so I'm not sure if this is just a stupid mistake on my part ... but ...
I created a new package with cargo new
, installed Argonautica 0.2.0, and copy-pasted the example code from the documentation into main.rs
:
extern crate argonautica;
use argonautica::Hasher;
fn main() {
let mut hasher = Hasher::default();
let hash = hasher
.with_password("P@ssw0rd")
.with_secret_key("\
secret key that you should really store in a .env file \
instead of in code, but this is just an example\
")
.hash()
.unwrap();
println!("{}", &hash);
// 👆 prints a hash, which will be random since the default Hasher uses a random salt
}
Unfortunately, I get a segfault when I try cargo run
. Again, I have no idea what I'm doing, but someone suggested I try lldb
, so here's the backtrace reported thereby:
(lldb) thread backtrace
* thread #2, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
* frame #0: 0x00007fff71a28476 libdyld.dylib`stack_not_16_byte_aligned_error
frame #1: 0x000070000016da50
frame #2: 0x000000010000e482 secure_memo`next_addresses(address_block=0x000070000016e738, input_block=0x000070000016e338) at opt.c:168:5
frame #3: 0x000000010000e08d secure_memo`fill_segment(instance=0x00007ffeefbfda38, position=(pass = 0, lane = 0, slice = '\0', index = 0)) at opt.c:217:13
frame #4: 0x000000010000c21c secure_memo`fill_segment_thr(thread_data=0x0000000100500060) at core.c:275:5
frame #5: 0x00007fff71c43d76 libsystem_pthread.dylib`_pthread_start + 125
frame #6: 0x00007fff71c405d7 libsystem_pthread.dylib`thread_start + 15
Did I do something wrong in the initial setup? Maybe this isn't compatible with the below version of Rust, or macOS, or something? I don't even know where to start debugging this! 🤣
-
rustc -V
:rustc 1.38.0 (625451e37 2019-09-23)
- OS: macOS Catalina v10.15 (19A583)
It looks like this is specific to building with the "simd"
flag in Cargo.toml
; the example-code works fine with that disabled.
Someone on Twitter pointed out that there's a few Google results out there for "catalina stack_not_16_byte_aligned_error", which I see includes this one which is also about cryptography libraries, apparently; and this one with some details about default clang
settings changing. Again, this is all over my head, but I hope that's helpful information if you end up trying to track down this bug!