unrar broken in FreeBSD version

Get help, report and discuss bugs.
Post Reply
thxtex
Posts: 2
Joined: 10 Jun 2018, 08:14

unrar broken in FreeBSD version

Post by thxtex » 10 Jun 2018, 08:20

Just installed the FreeBSD version on my FreeNAS. After some failed downloads I noticed that unrar is not working.
The error I see is.

root@freenas:/mnt/iocage/jails/nzbget_2/root/nzbget # ./unrar
Segmentation fault (core dumped)
root@freenas:/mnt/iocage/jails/nzbget_2/root/nzbget #

sanderj
Posts: 102
Joined: 10 Feb 2014, 21:46

Re: unrar broken in FreeBSD version

Post by sanderj » 10 Jun 2018, 16:57

Same same, or different as https://github.com/nzbget/nzbget/issues/542 ?

As a workaround, you can use unrar from nzbget 19.1 or from FreeBSD itself

Differences in binaries within nzbget 20.0:

Code: Select all

$ /root/nzbget-20.0/unrar
Segmentation fault (core dumped)

$ file /root/nzbget-20.0/unrar
/root/nzbget-20.0/unrar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for FreeBSD 10.1, FreeBSD-style, stripped
$ file /root/nzbget-20.0/7za 
/root/nzbget-20.0/7za: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 10.1, FreeBSD-style, not stripped
$ file /root/nzbget-20.0/nzbget
/root/nzbget-20.0/nzbget: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 10.1, FreeBSD-style, stripped
$ 
So ... "SYSV"?

For 19.1 everything is "FreeBSD":

Code: Select all

$ file nzbget-19.1/nzbget
nzbget-19.1/nzbget: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 9.1, stripped
$ file nzbget-19.1/unrar
nzbget-19.1/unrar: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 9.1, stripped
$ file nzbget-19.1/7za 
nzbget-19.1/7za: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 9.1, stripped
$ 

hugbug
Developer & Admin
Posts: 7006
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: unrar broken in FreeBSD version

Post by hugbug » 11 Jun 2018, 06:38

thxtex, please use unrar from your system distribution. In NZBGet you can set the path via option UnrarCmd.

sanderj, it crashes when trying to open some config file; that's what I can see in debugger callstack.

v19 and v20 are compiled using different toolchains (see #425).

Strange about SYSV indeed.

sanderj
Posts: 102
Joined: 10 Feb 2014, 21:46

Re: unrar broken in FreeBSD version

Post by sanderj » 11 Jun 2018, 18:03

Yes, but that seems fake: even after filling those config files there is a core dump

gdb on the unrar.code does not reveal function calls (just hex code). Is that because it is a stripped (so no debug) unrar binary? Or am I using gdb wrong?

Plain system:

Code: Select all

$ truss /home/sander/nzbget-20.0/unrar
readlink("/etc/malloc.conf",0x7fffffffe6e0,1024) ERR#2 'No such file or directory'
issetugid()					 = 0 (0x0)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34363158528 (0x800343000)
munmap(0x800343000,4194304)			 = 0 (0x0)
mmap(0x0,8384512,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34363158528 (0x800343000)
munmap(0x800343000,774144)			 = 0 (0x0)
munmap(0x800800000,3416064)			 = 0 (0x0)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34368126976 (0x800800000)
sysarch(AMD64_SET_FSBASE,0x7fffffffeb58)	 = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffeae8)		 = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffeae8)		 = 0 (0x0)
ioctl(0,TIOCGETA,0x7fffffffeae8)		 = 0 (0x0)
sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
sigaction(SIGINT,{ 0x245490 SA_RESTART|SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigprocmask(SIG_SETMASK,{ },0x0)		 = 0 (0x0)
sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
sigaction(SIGTERM,{ 0x245490 SA_RESTART|SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigprocmask(SIG_SETMASK,{ },0x0)		 = 0 (0x0)
access("/home/sander/.rarrc",F_OK)		 ERR#2 'No such file or directory'
access("/etc/.rarrc",F_OK)			 ERR#2 'No such file or directory'
access("/etc/rar/.rarrc",F_OK)			 ERR#2 'No such file or directory'
access("/usr/lib/.rarrc",F_OK)			 ERR#2 'No such file or directory'
access("/usr/local/lib/.rarrc",F_OK)		 ERR#2 'No such file or directory'
access("/usr/local/etc/.rarrc",F_OK)		 ERR#2 'No such file or directory'
SIGNAL 11 (SIGSEGV)
process killed, signal = 11 (core dumped)
$ 
With /etc/malloc.conf and /home/sander/.rarrc filled, there is still a core dump:

Code: Select all

$ truss /home/sander/nzbget-20.0/unrar
readlink("/etc/malloc.conf","abort:false,junk:false",1024) = 22 (0x16)
issetugid()					 = 0 (0x0)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34363158528 (0x800343000)
munmap(0x800343000,4194304)			 = 0 (0x0)
mmap(0x0,8384512,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34363158528 (0x800343000)
munmap(0x800343000,774144)			 = 0 (0x0)
munmap(0x800800000,3416064)			 = 0 (0x0)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34368126976 (0x800800000)
sysarch(AMD64_SET_FSBASE,0x7fffffffeb68)	 = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffeaf8)		 = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffeaf8)		 = 0 (0x0)
ioctl(0,TIOCGETA,0x7fffffffeaf8)		 = 0 (0x0)
sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
sigaction(SIGINT,{ 0x245490 SA_RESTART|SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigprocmask(SIG_SETMASK,{ },0x0)		 = 0 (0x0)
sigprocmask(SIG_SETMASK,{ SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2 },{ }) = 0 (0x0)
sigaction(SIGTERM,{ 0x245490 SA_RESTART|SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigprocmask(SIG_SETMASK,{ },0x0)		 = 0 (0x0)
access("/home/sander/.rarrc",F_OK)		 = 0 (0x0)
SIGNAL 11 (SIGSEGV)
process killed, signal = 11 (core dumped)
$ 
gdb on core:

Code: Select all

$ gdb unrar
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols found)...
(gdb) core unrar.core 
warning: core file may not match specified executable file.
Core was generated by `./unrar'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000248864 in ?? ()
(gdb) bt
#0  0x0000000000248864 in ?? ()
#1  0x000000000024baf6 in ?? ()
#2  0x000000000025798a in ?? ()
#3  0x00000000002839be in ?? ()
#4  0x00000000002820c8 in ?? ()
#5  0x000000000023f31d in ?? ()
#6  0x000000000023f16f in ?? ()
#7  0x0000000000000001 in ?? ()
#8  0x00007fffffffedd8 in ?? ()
#9  0x0000000000000000 in ?? ()
(gdb) 

hugbug
Developer & Admin
Posts: 7006
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: unrar broken in FreeBSD version

Post by hugbug » 12 Jun 2018, 13:25

sanderj wrote:
11 Jun 2018, 18:03
gdb on the unrar.code does not reveal function calls (just hex code). Is that because it is a stripped (so no debug) unrar binary? Or am I using gdb wrong?
Yes, it's because it is stripped. It is also compiled in optimised mode making it harder to debug. I'll send you a binary compiled in debug mode with symbols, if you want to try it.

sanderj
Posts: 102
Joined: 10 Feb 2014, 21:46

Re: unrar broken in FreeBSD version

Post by sanderj » 12 Jun 2018, 16:23

OK, thanks. Result:

Code: Select all

$ chmod +x unrar-bsd 
$ ./unrar-bsd 
Segmentation fault (core dumped)
$ ll unrar-bsd*
-rwxr-xr-x  1 sander  sander  - 1676360 Jun 12 18:15 unrar-bsd*
-rw-------  1 sander  sander  - 8855552 Jun 12 20:17 unrar-bsd.core
$ 
OK, "good".

Now gdb:

Code: Select all

$ gdb unrar-bsd
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols found)...
(gdb) core unrar-bsd.core 
warning: core file may not match specified executable file.
Core was generated by `./unrar-bsd'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000000002479f4 in _thr_cancel_enter ()
[New LWP 100078]
(gdb) bt
#0  0x00000000002479f4 in _thr_cancel_enter ()
#1  0x000000000024ac86 in open ()
#2  0x0000000000257e43 in File::Open ()
#3  0x00000000002929ea in ReadTextFile ()
#4  0x000000000028fbae in CommandData::ReadConfig ()
#5  0x000000000023e351 in main ()
(gdb) 
So: main () -> CommandData::ReadConfig () -> ReadTextFile () -> File::Open () -> open () -> _thr_cancel_enter ()

Hmmm ... so indeed trying to read / open a (text?) file ... but which one?

hugbug
Developer & Admin
Posts: 7006
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: unrar broken in FreeBSD version

Post by hugbug » 12 Jun 2018, 16:28

You should be able to run the program within debugger. Then you can set breakpoints and inspect program variables. I'm not a specialist on gdb but there should be manuals.

thxtex
Posts: 2
Joined: 10 Jun 2018, 08:14

Re: unrar broken in FreeBSD version

Post by thxtex » 13 Jun 2018, 15:54

hugbug wrote:
11 Jun 2018, 06:38
thxtex, please use unrar from your system distribution. In NZBGet you can set the path via option UnrarCmd.
Just replaced unrar with another working one. Thanks...

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests