Closed ElTopo closed 8 years ago
Hi,
I've upgraded file to latest 5.25, but it still behaves the same way:
root@unknown:/tmp/home/root# /opt/bin/file -v
file-5.25
magic file from /opt/share/misc/magic
root@unknown:/tmp/home/root# /opt/bin/file /opt/bin/nano
/opt/bin/nano: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /opt/lib/ld-uClibc.so.0, stripped
Segmentation fault
root@unknown:/tmp/home/root# strace /opt/bin/file /opt/bin/nano
execve("/opt/bin/file", ["/opt/bin/file", "/opt/bin/nano"], [/* 14 vars */]) = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/opt/bin/file", 4096) = 13
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_UNINITIALIZED, -1, 0) = 0x2aaaf000
open("/opt/lib/libmagic.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=153132, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_UNINITIALIZED, -1, 0) = 0x2aab0000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\220\27\0\0004\0\0\0"..., 4096) = 4096
mmap(NULL, 212992, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aac0000
mmap(0x2aac0000, 142480, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x2aac0000
mmap(0x2aaf3000, 2452, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x23000) = 0x2aaf3000
close(3) = 0
munmap(0x2aab0000, 4096) = 0
open("/opt/lib/libz.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=100980, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_UNINITIALIZED, -1, 0) = 0x2aab0000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\320\22\0\0004\0\0\0"..., 4096) = 4096
mmap(NULL, 163840, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaf4000
mmap(0x2aaf4000, 95652, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x2aaf4000
mmap(0x2ab1b000, 1992, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x17000) = 0x2ab1b000
close(3) = 0
munmap(0x2aab0000, 4096) = 0
open("/opt/lib/libc.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=780556, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_UNINITIALIZED, -1, 0) = 0x2aab0000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\240\275\0\0004\0\0\0"..., 4096) = 4096
mmap(NULL, 815104, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab1c000
mmap(0x2ab1c000, 717844, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x2ab1c000
mmap(0x2abdb000, 8092, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xaf000) = 0x2abdb000
mmap(0x2abdd000, 23092, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2abdd000
close(3) = 0
munmap(0x2aab0000, 4096) = 0
open("/opt/lib/libz.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=100980, ...}) = 0
close(3) = 0
open("/opt/lib/libc.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=780556, ...}) = 0
close(3) = 0
open("/opt/lib/libc.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=780556, ...}) = 0
close(3) = 0
stat("/opt/lib/ld-uClibc.so.1", {st_mode=S_IFREG|0755, st_size=31784, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_UNINITIALIZED, -1, 0) = 0x2aab0000
set_thread_area(0x2aab7460) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, "^\"\264\230", 4) = 4
close(3) = 0
mprotect(0x2abdb000, 4096, PROT_READ) = 0
mprotect(0x2aabe000, 4096, PROT_READ) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
brk(0) = 0x414000
brk(0x415000) = 0x415000
brk(0x416000) = 0x416000
brk(0x417000) = 0x417000
stat64("/root/.magic.mgc", 0x7fc569a8) = -1 ENOENT (No such file or directory)
stat64("/root/.magic", 0x7fc569a8) = -1 ENOENT (No such file or directory)
open("/opt/share/misc/magic.mgc", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3881592, ...}) = 0
mmap(NULL, 3883008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x2abe3000
read(3, "\34\4\36\361\r\0\0\0\233*\0\0\375\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 3881592) = 3881592
close(3) = 0
mmap(NULL, 1052672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x2af97000
lstat64("/opt/bin/nano", {st_mode=S_IFREG|0755, st_size=230492, ...}) = 0
stat64("/opt/bin/nano", {st_mode=S_IFREG|0755, st_size=230492, ...}) = 0
open("/opt/bin/nano", O_RDONLY|O_LARGEFILE) = 3
fcntl64(3, F_GETFL) = 0x2000 (flags O_RDONLY|O_LARGEFILE)
fcntl64(3, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\2\0\10\0\1\0\0\0pT@\0004\0\0\0"..., 1048576) = 230492
mmap(NULL, 925696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x2b098000
brk(0x44d000) = 0x44d000
_llseek(3, 0, [0], SEEK_SET) = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=230492, ...}) = 0
pread64(3, "\6\0\0\0004\0\0\0004\0@\0004\0@\0 \1\0\0 \1\0\0\5\0\0\0\4\0\0\0", 32, 52) = 32
pread64(3, "\3\0\0\0T\1\0\0T\1@\0T\1@\0\30\0\0\0\30\0\0\0\4\0\0\0\1\0\0\0", 32, 84) = 32
pread64(3, "/opt/lib/ld-uClibc.so.0\0", 24, 340) = 24
pread64(3, "\3\0\0pp\1\0\0p\1@\0p\1@\0\30\0\0\0\30\0\0\0\4\0\0\0\10\0\0\0", 32, 116) = 32
pread64(3, "\0\0\0p\210\1\0\0\210\1@\0\210\1@\0\30\0\0\0\30\0\0\0\4\0\0\0\4\0\0\0", 32, 148) = 32
pread64(3, "\1\0\0\0\0\0\0\0\0\0@\0\0\0@\0\2249\3\0\2249\3\0\5\0\0\0\0\0\1\0", 32, 180) = 32
pread64(3, "\1\0\0\0\2249\3\0\2249D\0\2249D\0\344\r\0\0|\21\0\0\6\0\0\0\0\0\1\0", 32, 212) = 32
pread64(3, "\2\0\0\0\240\1\0\0\240\1@\0\240\1@\0\340\0\0\0\340\0\0\0\4\0\0\0\4\0\0\0", 32, 244) = 32
pread64(3, "Q\345td\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7\0\0\0\20\0\0\0", 32, 276) = 32
pread64(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0", 32, 308) = 32
pread64(3, "\1\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\350~\3\0\354\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230452) = 40
pread64(3, ".shstrtab\0.interp\0.MIPS.abiflags"..., 49, 229097) = 49
pread64(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229332) = 40
pread64(3, "\0.shstrtab\0.interp\0.MIPS.abiflag"..., 49, 229096) = 49
pread64(3, "\v\0\0\0\1\0\0\0\2\0\0\0T\1@\0T\1\0\0\30\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229372) = 40
pread64(3, ".interp\0.MIPS.abiflags\0.reginfo\0"..., 49, 229107) = 49
pread64(3, "\23\0\0\0*\0\0p\2\0\0\0p\1@\0p\1\0\0\30\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229412) = 40
pread64(3, ".MIPS.abiflags\0.reginfo\0.dynamic"..., 49, 229115) = 49
pread64(3, "\"\0\0\0\6\0\0p\2\0\0\0\210\1@\0\210\1\0\0\30\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229452) = 40
pread64(3, ".reginfo\0.dynamic\0.hash\0.dynsym\0"..., 49, 229130) = 49
pread64(3, "+\0\0\0\6\0\0\0\2\0\0\0\240\1@\0\240\1\0\0\340\0\0\0\7\0\0\0\0\0\0\0"..., 40, 229492) = 40
pread64(3, ".dynamic\0.hash\0.dynsym\0.dynstr\0."..., 49, 229139) = 49
pread64(3, "4\0\0\0\5\0\0\0\2\0\0\0\200\2@\0\200\2\0\0008\f\0\0\6\0\0\0\0\0\0\0"..., 40, 229532) = 40
pread64(3, ".hash\0.dynsym\0.dynstr\0.init\0.tex"..., 49, 229148) = 49
pread64(3, ":\0\0\0\v\0\0\0\2\0\0\0\270\16@\0\270\16\0\0P \0\0\7\0\0\0\1\0\0\0"..., 40, 229572) = 40
pread64(3, ".dynsym\0.dynstr\0.init\0.text\0.MIP"..., 49, 229154) = 49
pread64(3, "B\0\0\0\3\0\0\0\2\0\0\0\10/@\0\10/\0\0y\26\0\0\0\0\0\0\0\0\0\0"..., 40, 229612) = 40
pread64(3, ".dynstr\0.init\0.text\0.MIPS.stubs\0"..., 49, 229162) = 49
pread64(3, "J\0\0\0\1\0\0\0\6\0\0\0\204E@\0\204E\0\0l\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229652) = 40
pread64(3, ".init\0.text\0.MIPS.stubs\0.fini\0.r"..., 49, 229170) = 49
pread64(3, "P\0\0\0\1\0\0\0\6\0\0\0\360E@\0\360E\0\0\240\214\2\0\0\0\0\0\0\0\0\0"..., 40, 229692) = 40
pread64(3, ".text\0.MIPS.stubs\0.fini\0.rodata\0"..., 49, 229176) = 49
pread64(3, "V\0\0\0\1\0\0\0\6\0\0\0\220\322B\0\220\322\2\0\340\t\0\0\0\0\0\0\0\0\0\0"..., 40, 229732) = 40
pread64(3, ".MIPS.stubs\0.fini\0.rodata\0.eh_fr"..., 49, 229182) = 49
pread64(3, "b\0\0\0\1\0\0\0\6\0\0\0p\334B\0p\334\2\0L\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229772) = 40
pread64(3, ".fini\0.rodata\0.eh_frame\0.ctors\0."..., 49, 229194) = 49
pread64(3, "h\0\0\0\1\0\0\0\2\0\0\0\300\334B\0\300\334\2\0\320\\\0\0\0\0\0\0\0\0\0\0"..., 40, 229812) = 40
pread64(3, ".rodata\0.eh_frame\0.ctors\0.dtors\0"..., 49, 229200) = 49
pread64(3, "p\0\0\0\1\0\0\0\2\0\0\0\2209C\0\2209\3\0\4\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229852) = 40
pread64(3, ".eh_frame\0.ctors\0.dtors\0.jcr\0.da"..., 49, 229208) = 49
pread64(3, "z\0\0\0\1\0\0\0\3\0\0\0\2249D\0\2249\3\0\10\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229892) = 40
pread64(3, ".ctors\0.dtors\0.jcr\0.data.rel.ro\0"..., 49, 229218) = 49
pread64(3, "\201\0\0\0\1\0\0\0\3\0\0\0\2349D\0\2349\3\0\10\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229932) = 40
pread64(3, ".dtors\0.jcr\0.data.rel.ro\0.data\0."..., 49, 229225) = 49
pread64(3, "\210\0\0\0\1\0\0\0\3\0\0\0\2449D\0\2449\3\0\4\0\0\0\0\0\0\0\0\0\0\0"..., 40, 229972) = 40
pread64(3, ".jcr\0.data.rel.ro\0.data\0.rld_map"..., 49, 229232) = 49
pread64(3, "\215\0\0\0\1\0\0\0\3\0\0\0\2509D\0\2509\3\0\200\1\0\0\0\0\0\0\0\0\0\0"..., 40, 230012) = 40
pread64(3, ".data.rel.ro\0.data\0.rld_map\0.got"..., 49, 229237) = 49
pread64(3, "\232\0\0\0\1\0\0\0\3\0\0\0000;D\0000;\3\0000\4\0\0\0\0\0\0\0\0\0\0"..., 40, 230052) = 40
pread64(3, ".data\0.rld_map\0.got\0.sdata\0.sbss"..., 49, 229250) = 49
pread64(3, "\240\0\0\0\1\0\0\0\3\0\0\0`?D\0`?\3\0\4\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230092) = 40
pread64(3, ".rld_map\0.got\0.sdata\0.sbss\0.bss\0"..., 49, 229256) = 49
pread64(3, "\251\0\0\0\1\0\0\0\3\0\0\20p?D\0p?\3\0\4\10\0\0\0\0\0\0\0\0\0\0"..., 40, 230132) = 40
pread64(3, ".got\0.sdata\0.sbss\0.bss\0.comment\0"..., 49, 229265) = 49
pread64(3, "\256\0\0\0\1\0\0\0\3\0\0\20tGD\0tG\3\0\4\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230172) = 40
pread64(3, ".sdata\0.sbss\0.bss\0.comment\0.pdr\0"..., 49, 229270) = 49
pread64(3, "\265\0\0\0\10\0\0\0\3\0\0\20xGD\0xG\3\0004\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230212) = 40
pread64(3, ".sbss\0.bss\0.comment\0.pdr\0.gnu.at"..., 49, 229277) = 49
pread64(3, "\273\0\0\0\10\0\0\0\3\0\0\0\260GD\0xG\3\0`\3\0\0\0\0\0\0\0\0\0\0"..., 40, 230252) = 40
pread64(3, ".bss\0.comment\0.pdr\0.gnu.attribut"..., 49, 229283) = 49
pread64(3, "\300\0\0\0\1\0\0\0000\0\0\0\0\0\0\0xG\3\0?\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230292) = 40
pread64(3, ".comment\0.pdr\0.gnu.attributes\0.m"..., 49, 229288) = 49
pread64(3, "\311\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\270G\3\0 7\0\0\0\0\0\0\0\0\0\0"..., 40, 230332) = 40
pread64(3, ".pdr\0.gnu.attributes\0.mdebug.abi"..., 49, 229297) = 49
pread64(3, "\316\0\0\0\365\377\377o\0\0\0\0\0\0\0\0\330~\3\0\20\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230372) = 40
pread64(3, ".gnu.attributes\0.mdebug.abi32\0\0\0"..., 49, 229302) = 49
pread64(3, "\336\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\350~\3\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230412) = 40
pread64(3, ".mdebug.abi32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 49, 229318) = 49
pread64(3, "\1\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\350~\3\0\354\0\0\0\0\0\0\0\0\0\0\0"..., 40, 230452) = 40
munmap(0x2b098000, 925696) = 0
munmap(0x2af97000, 1052672) = 0
close(3) = 0
write(1, "/opt/bin/nano: ELF 32-bit LSB ex"..., 144/opt/bin/nano: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /opt/lib/ld-uClibc.so.0, stripped
) = 144
munmap(0x2abe3000, 3883008) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x2abe313c} ---
+++ killed by SIGSEGV +++
Segmentation fault
The same happens with other targets too. Currently I don't have a fix for this.
I noticed this same issue when cross-compiling file for my project tomatoware, but when I do a native compile using tomatoware itself, no segfault. I ran into this thread that suggested it was fixed in post 5.25 git HEAD. http://bugs.gw.com/view.php?id=494
I then tried the cross-compilation from git HEAD and it no longer segfaults for me.
@lancethepants nice find, thanks. And this seems to be the fix: https://github.com/file/file/commit/003c7fc40ec4b586de2225b072be438f866373d2 Now need to test this patch
@lancethepants thanks! hopefully this also fixs some other crash issues I have with different tools.
@ElTopo file 5.25+git20160111-1
is online for a while now, and doesn't segfault. Please confirm and close the issue
@alllexx88 just upgraded to file-5.25 and it does not crash anymore so this issue is closed, thanks!
system: asus rt-ac66w (mipsel-ng, up to date) firmware: asuswrt-Merlin 380.57
file-5.12 issues "segmentation fault" just before it exits (after file info correctly displayed). This issue could have been fixed in newer version of file, there was a bug report here: https://bugs.mageia.org/show_bug.cgi?id=13701 So I hope we'll see a newer version of file soon.
Here are some commands and results:
$ file --version file-5.12 magic file from /opt/share/misc/magic
$ file /tmp/syslog.log /tmp/syslog.log: UTF-8 Unicode text Segmentation fault
$ strace file /tmp/syslog.log ...... ...... mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x2ae1f000 lstat64("/tmp/syslog.log", {st_mode=S_IFREG|0666, st_size=30291, ...}) = 0 stat64("/tmp/syslog.log", {st_mode=S_IFREG|0666, st_size=30291, ...}) = 0 open("/tmp/syslog.log", O_RDONLY|O_LARGEFILE) = 3 fcntl64(3, F_GETFL) = 0x2000 (flags O_RDONLY|O_LARGEFILE) fcntl64(3, F_SETFL, O_RDONLY|O_LARGEFILE) = 0 read(3, "Jul 31 17:00:09 syslogd started:"..., 262144) = 30291 brk(0x41c000) = 0x41c000 brk(0x43a000) = 0x43a000 brk(0x441000) = 0x441000 brk(0x45f000) = 0x45f000 brk(0x48b000) = 0x48b000 brk(0x43a000) = 0x43a000 munmap(0x2ae1f000, 266240) = 0 close(3) = 0 write(1, "/tmp/syslog.log: UTF-8 Unicode t"..., 36/tmp/syslog.log: UTF-8 Unicode text ) = 36 munmap(0x2abdf000, 2359296) = 0 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x2ae093ac} --- +++ killed by SIGSEGV +++ Segmentation fault