vasi / squashfuse

FUSE filesystem to mount squashfs archives
Other
291 stars 66 forks source link

fuse_parse_cmdline issues on NetBSD #18

Open krytarowski opened 7 years ago

krytarowski commented 7 years ago

I'm getting crashes with squashfuse on NetBSD. I narrowed it down to prototype mismatch between fuse_parse_cmdline() in this package and in system.

During build:

--- libfuseprivate_la-fuseprivate.lo ---
fuseprivate.c: In function 'sqfs_usage':
fuseprivate.c:105:3: warning: implicit declaration of function 'fuse_parse_cmdline' [-Wimplicit-function-declaration]
   fuse_parse_cmdline(&args, NULL, NULL, NULL);

Backtrace

$ gdb --args squashfuse -v                                                                                                                                    
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from squashfuse...done.
(gdb) r
Starting program: /usr/pkg/bin/squashfuse -v
squashfuse 0.1.100 (c) 2012 Dave Vasilevsky

Usage: /usr/pkg/bin/squashfuse [options] ARCHIVE MOUNTPOINT

Program received signal SIGSEGV, Segmentation fault.
fuse_parse_cmdline (args=0x7f7fff446c90, opts=0x0) at /usr/src/lib/librefuse/refuse_lowlevel.c:125
125     memset(opts, 0, sizeof(*opts));
(gdb) bt
#0  fuse_parse_cmdline (args=0x7f7fff446c90, opts=0x0) at /usr/src/lib/librefuse/refuse_lowlevel.c:125
#1  0x000000000040628e in sqfs_usage (progname=0x7f7fff447470 "/usr/pkg/bin/squashfuse", fuse_usage=true) at fuseprivate.c:105
#2  0x00000000004018da in main (argc=2, argv=0x7f7fff446eb0) at hl.c:305

Browsing libfuse examples they confirm that the function prototype is different out there - with two arguments.

vasi commented 4 years ago

I can't reproduce this. What version of NetBSD is it?

krytarowski commented 4 years ago

Back in 2017 it was probably pre-NetBSD-8.

krytarowski commented 4 years ago

NetBSD/src/lib/librefuse/fuse_lowlevel.h int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts);

fuseprivate.c fuse_parse_cmdline(&args, NULL, NULL, NULL);

vasi commented 4 years ago

Great, thanks! I'll look into it.

vasi commented 4 years ago

On NetBSD 8.1, I have fuse-2.9.3 installed with pkgin, and everything Just Works™️. The header you mentioned (which lives in /usr/include/fuse_lowlevel.h) doesn't include fuse_lowlevel_new, so it's odd that configure found it. It's really barely a stub, I don't know if any real lowlevel FUSE FS can compile against that.

Any more clues to reproducing this?

krytarowski commented 4 years ago

I checked squashfuse-0.1.103 and the problem is resolved in this version.

krytarowski commented 4 years ago

Opps. It still builds but still breaks in runtime.

--- squashfuse_extract-extract.o ---
extract.c: In function 'sqfs_stat':
extract.c:51:17: warning: implicit declaration of function 'sqfs_makedev'; did you mean 'sqfs_mode'? [-Wimplicit-function-declaration]
   st->st_rdev = sqfs_makedev(inode->xtra.dev.major,
                 ^~~~~~~~~~~~
                 sqfs_mode
--- libsquashfuse_la-table.lo ---
  CC       libsquashfuse_la-table.lo
--- libfuseprivate_la-fuseprivate.lo ---
fuseprivate.c: In function 'sqfs_usage':
fuseprivate.c:105:3: warning: implicit declaration of function 'fuse_parse_cmdline'; did you mean 'fuse_daemonize'? [-Wimplicit-function-declaration]
   fuse_parse_cmdline(&args, NULL, NULL, NULL);
   ^~~~~~~~~~~~~~~~~~
   fuse_daemonize
--- libsquashfuse_la-dir.lo ---
(No debugging symbols found in squashfuse)
(gdb) r
Starting program: /usr/pkg/bin/squashfuse 
squashfuse 0.1.103 (c) 2012 Dave Vasilevsky

Usage: /usr/pkg/bin/squashfuse [options] ARCHIVE MOUNTPOINT

Program received signal SIGSEGV, Segmentation fault.
fuse_parse_cmdline (args=0x7f7fffffe4f0, opts=0x0) at /usr/src/lib/librefuse/refuse_lowlevel.c:125
125             memset(opts, 0, sizeof(*opts));
(gdb) bt
#0  fuse_parse_cmdline (args=0x7f7fffffe4f0, opts=0x0) at /usr/src/lib/librefuse/refuse_lowlevel.c:125
#1  0x00007f7ff7400c16 in sqfs_usage () from /usr/pkg/lib/libfuseprivate.so.0
#2  0x0000000000401c4c in ?? ()
#3  0x000000000040143b in ?? ()
#4  0x00007f7ff7c0c178 in ?? () from /usr/libexec/ld.elf_so
#5  0x0000000000000001 in ?? ()
#6  0x00007f7fffffed00 in ?? ()
#7  0x0000000000000000 in ?? ()

NetBSD chieftec 9.99.46 NetBSD 9.99.46 (GENERIC) #2: Wed Feb 12 11:41:14 CET 2020 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64

vasi commented 4 years ago

Oooh nice, more data! Can you send the config.log please?

krytarowski commented 4 years ago

The bug is obvious that there is mismatch in function prototypes.

If you already have 8.1, you can try to debug it yourself.

vasi commented 4 years ago

Like I said, I have 8.1 and I can't reproduce that. I see these results using squashfuse master:

So clearly there's something else going on in your case. Did you provide arguments to configure? Did you get libfuse from somewhere else? Is there some installation set that contains libfuse?

krytarowski commented 4 years ago

I have packaged it as fuse-squashfuse in pkgsrc-wip.

https://github.com/NetBSD/pkgsrc-wip/tree/master/fuse-squashfuse

https://pkgsrc.org/wip/

wbender-wurl commented 2 years ago

I got a similar error on Ubuntu 20 following these instructions https://engineering.fb.com/2018/07/13/data-infrastructure/xars-a-more-efficient-open-source-system-for-self-contained-executables/ warning: implicit declaration of function ‘sqfs_makedev’; did you mean ‘sqfs_mode’? [-Wimplicit-function-declaration]

Oddly enough, running ./autogen.sh before ./configure fixed it.