zboxfs / zbox

Zero-details, privacy-focused in-app file system.
https://zbox.io/fs/
Apache License 2.0
1.53k stars 74 forks source link

SIGABRT on opening Repo #45

Closed theduke closed 4 years ago

theduke commented 4 years ago

I'm getting a SIGABRT on opening a repo. The error happens both with libsodium-bundled and with the system libsodium.

Host: Arch Linux Zbox: 0.8.3

fn main() {
    let mut repo = zbox::RepoOpener::new()
        .open("mem://", "password")
        // .open("file://file.zbox", "password")
        .unwrap();
}
Program received signal SIGABRT, Aborted.
0x00007ffff7dd1755 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7dd1755 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7dbc851 in abort () from /usr/lib/libc.so.6
#2  0x0000555555587245 in sodium_misuse () at sodium/core.c:199
#3  0x0000555555715f7d in _sodium_malloc (size=<optimized out>)
    at sodium/utils.c:578
#4  sodium_malloc (size=<optimized out>) at sodium/utils.c:610
#5  0x00005555555ec5fa in zbox::base::crypto::SafeBox<T>::new_empty ()
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/base/crypto.rs:163
#6  0x000055555592178a in zbox::volume::storage::file::file_armor::FileArmor<T>::new (base=0x555555a74b60)
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/volume/storage/file/file_armor.rs:183
#7  0x0000555555595cc9 in zbox::volume::storage::file::file::FileStorage::new (
    base=0x55555599d007)
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/volume/storage/file/file.rs:40
#8  0x00005555555feaff in zbox::volume::storage::storage::parse_uri (uri=...)
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/volume/storage/storage.rs:45
#9  0x00005555555fec48 in zbox::volume::storage::storage::Storage::new (uri=...)
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/volume/storage/storage.rs:144
#10 0x00005555555b328f in zbox::volume::volume::Volume::new (uri=...)
    at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/volume/volume.rs:42
#11 0x00005555555fc91d in zbox::fs::fs::Fs::open (uri=..., pwd=...,
--Type <RET> for more, q to quit, c to continue without paging--
     at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/fs/fs.rs:162
#12 0x000055555559087f in zbox::repo::Repo::open (uri=..., pwd=..., read_only=false) at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/repo.rs:682
#13 0x0000555555590266 in zbox::repo::RepoOpener::open (self=0x7fffffffe5b8, uri=..., pwd=...) at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.3/src/repo.rs:252
#14 0x0000555555587520 in zbox_repro::main () at src/main.rs:2
burmecia commented 4 years ago

Hi @theduke , did you call the zbox::init_env function at the beginning? It is essential to get libsodium work.

theduke commented 4 years ago

That was it. Does libsodium provide a API to determine if it has been initialized? If so you could check and panic with a more informative message.

burmecia commented 4 years ago

I don't think libsodium provided that API nor I think it is necessary. That initialize function is supposed to run once before any others, and it can be called multiple times. Like any other libraries, that is just one-off task and should keep simple as possible. So I cannot see any necessities to have a such API.

theduke commented 4 years ago

The point is for zbox to check if the initialization was already done before opening a repo and panick, or alternatively to auto-initialize when creating the repo.

A SIGABRT is not something that should happen in a Rust library, so I'd consider this a API zbox API design issue.

burmecia commented 4 years ago

I can't see any reason need to check the initialization status, simply call that function in your program's initialize code and then forget about it, it isn't that hard I think.

theduke commented 4 years ago

It's not that hard, but a Rust library that can SIGABRT with regular usage just has a bad API design imo.

burmecia commented 4 years ago

Just close this issue, because this behavior is consistent with libsodium which will also SIGABRT when not initialized.