You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2019/07/08 15:51:20 UTC

"svn add" crashes in case of missing magic.mgc

Hi all,

I recently set up a new Synology NAs and tried to version some custom
scripts. While some SVN client was already available and checking out
an empty directory worked as expected, adding some file to the working
copy didn't. There wasn't any error by default, it seemed that adding
was successful, but it wasn't, instead the working copy was locked.

> svn add dasikomp_buero_hm
> svn st

>   L     .
> ?       @eaDir
> ?       dasikomp_buero_hm
[...]

Explicitly asking for the last error showed the problem:

> svn add %f && echo $@
> sh: line 1: 20166 Aborted                 (core dumped) svn add "test.txt"

Making strace available[1] lead to the root cause being the file
magic.mgc not found in usual places:

> strace svn add %f
[...]
> stat("/root/.magic.mgc", 0x7fff5f129370) = -1 ENOENT (No such file or directory)
> stat("/root/.magic", 0x7fff5f129370)    = -1 ENOENT (No such file or directory)
> access("/opt/share/misc/magic.mime.mgc", R_OK) = -1 ENOENT (No such file or directory)
> open("/opt/share/misc/magic.mgc", O_RDONLY) = -1 ENOENT (No such file or directory)
> rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
> tgkill(21192, 21192, SIGABRT)           = 0
> --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=21192, si_uid=0} ---

Instead, the file was placed in the following path, which is a symlink
only as well:

> /usr/share/file/misc/magic.mgc -> /var/packages/DiagnosisTool/target/usr/share/file/misc/magic.mgc

The link target is part of DiagnosisTools, which is interesting
because that's exactly what has been installed using [1] to make
strace available. Without that package I didn't find any other
suitable file on the NAS.

Some things coming into my mind:

1. Should "svn add" really crash silently?
2. Should the symlink be recognized and tried like the other pathes?
3. Is path handling even something SVN cares about on it's own vs.
   libmagic or else?

The installed SVN-client:

> svn, version 1.9.7 (r1800392)
>    compiled Jan 11 2018, 08:42:15 on x86_64-openwrt-linux-gnu

Is that worth filing a bug or fixed or known or ...? Thanks!

[1]: https://www.synology-wiki.de/index.php/Synogear:_weitere_Tools

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: "svn add" crashes in case of missing magic.mgc

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Jul 09, 2019 at 11:58:35AM +0200, Thorsten Schöning wrote:
> Guten Tag Stefan Sperling,
> am Montag, 8. Juli 2019 um 20:36 schrieben Sie:
> 
> > As a workaround, you can disable use of libmagic in SVN's configuration.
> > In ~/.subversion/config, add these lines:
> 
> > [miscellany]
> > enable-magic-file = no
> 
> What would be the consequences of disabling? Do added files get some
> common fallback mime like octet-stream or none or forces "add" me to
> provide one?

The fallbacks are auto-props, and then octet-stream if the file
is considered binary or no svn:mime-type otherwise.

And you can always set a mime-type manually before committing a
newly added file.

Re: "svn add" crashes in case of missing magic.mgc

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Stefan Sperling,
am Montag, 8. Juli 2019 um 20:36 schrieben Sie:

> As a workaround, you can disable use of libmagic in SVN's configuration.
> In ~/.subversion/config, add these lines:

> [miscellany]
> enable-magic-file = no

What would be the consequences of disabling? Do added files get some
common fallback mime like octet-stream or none or forces "add" me to
provide one?

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: "svn add" crashes in case of missing magic.mgc

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Jul 08, 2019 at 07:03:38PM +0200, Thorsten Schöning wrote:
> Guten Tag Stefan Sperling,
> am Montag, 8. Juli 2019 um 18:10 schrieben Sie:
> 
> > SVN only calls the magic_open() function provided by libmagic.
> > It checks the return value and skips mime-type detection via
> > libmagic if an error occurs. I believe that, at the time, this
> > code was tested with and without a magic database file and both
> > cases worked. But I don't think we have regression tests for this...
> 
> It might perfectly be that there's something strange with that SVN
> client, because even if I make the file magic.mgc available to SVN by
> additionally linking in one of the checked places or using the
> environment variable "MAGIC", I see a lot of warnings about that file
> being invalid:
> 
> > /usr/share/file/misc/magic.mgc, 92: Warning: offset `Ancient_Realms' invalid
> > /usr/share/file/misc/magic.mgc, 93: Warning: offset `Armagon's_Lair' invalid
> > /usr/share/file/misc/magic.mgc, 94: Warning: offset `Into_The_Flood' invalid
> > /usr/share/file/misc/magic.mgc, 95: Warning: offset `Slaughterhouse' invalid
> > ' invalide/file/misc/magic.mgc, 96: Warning: offset `
> > ' invalide/file/misc/magic.mgc, 102: Warning: offset `METADATA
> > /usr/share/file/misc/magic.mgc, 103: Warning: offset `' invalid
> > /usr/share/file/misc/magic.mgc, 106: Warning: offset `' invalid
> > ' invalide/file/misc/magic.mgc, 108: Warning: offset `MozFASL
> > /usr/share/file/misc/magic.mgc, 109: Warning: offset `' invalid
> > /usr/share/file/misc/magic.mgc, 111: Warning: offset `' invalid
> > /usr/share/file/misc/magic.mgc, 112: Warning: offset `' invalid
> > /usr/share/file/misc/magic.mgc, 125: Warning: offset ` REMARK' invalid
> > /usr/share/file/misc/magic.mgc, 126: Warning: offset `' invalid
> > ' invalide/file/misc/magic.mgc, 127: Warning: offset `TypeLib
> > /usr/share/file/misc/magic.mgc, 128: Warning: offset `' invalid
> > /usr/share/file/misc/magic.mgc, 129: Warning: offset `' invalid
> 
> Looks like the linked libmagic is incompatible anyway with the
> provided file.
> 
> > If possible please try to reproduce with a newer version.
> [...]
> > Your best next step is to pin down the exact location of the 
> > crash with a debugger (either live or with a core file).
> > Is SVN crashing or is libmagic crashing?
> 
> I'll keep that in mind, but have very limited time currently for
> further research. No idea where to get symbol files from and stuff
> like that...
> 
> > (gdb) run add /tmp/svn_crash/test.txt
> > Starting program: /volume1/@entware-ng/opt/bin/svn add /tmp/svn_crash/test.txt
> > warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
> >
> > Program received signal SIGABRT, Aborted.
> > 0x00007ffff3d240f8 in raise () from /opt/lib/libc.so.6
> > (gdb) bt
> > #0  0x00007ffff3d240f8 in raise () from /opt/lib/libc.so.6
> > #1  0x00007ffff3d2552a in abort () from /opt/lib/libc.so.6
> > #2  0x00007ffff4711dd5 in ?? () from /opt/lib/libmagic.so.1
> > #3  0x00007ffff4716000 in ?? () from /opt/lib/libmagic.so.1
> > #4  0x00007ffff5c652ed in svn_magic.init () from /opt/lib/libsvn_subr-1.so.0
> > #5  0x00007ffff7b83600 in svn_client_add5 () from /opt/lib/libsvn_client-1.so.0
> > #6  0x00000000004077af in ?? ()
> > #7  0x000000000041c39a in ?? ()
> > #8  0x00000000004075b3 in ?? ()
> > #9  0x00007ffff3d11711 in __libc_start_main () from /opt/lib/libc.so.6
> > #10 0x0000000000407629 in ?? ()

Thanks for providing a trace!

This trace indicates the code is crashing inside libmagic.
There's nothing intelligent SVN could do to prevent this.

As a workaround, you can disable use of libmagic in SVN's configuration.
In ~/.subversion/config, add these lines:

[miscellany]
enable-magic-file = no

Regards,
Stefan

Re: "svn add" crashes in case of missing magic.mgc

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Stefan Sperling,
am Montag, 8. Juli 2019 um 18:10 schrieben Sie:

> SVN only calls the magic_open() function provided by libmagic.
> It checks the return value and skips mime-type detection via
> libmagic if an error occurs. I believe that, at the time, this
> code was tested with and without a magic database file and both
> cases worked. But I don't think we have regression tests for this...

It might perfectly be that there's something strange with that SVN
client, because even if I make the file magic.mgc available to SVN by
additionally linking in one of the checked places or using the
environment variable "MAGIC", I see a lot of warnings about that file
being invalid:

> /usr/share/file/misc/magic.mgc, 92: Warning: offset `Ancient_Realms' invalid
> /usr/share/file/misc/magic.mgc, 93: Warning: offset `Armagon's_Lair' invalid
> /usr/share/file/misc/magic.mgc, 94: Warning: offset `Into_The_Flood' invalid
> /usr/share/file/misc/magic.mgc, 95: Warning: offset `Slaughterhouse' invalid
> ' invalide/file/misc/magic.mgc, 96: Warning: offset `
> ' invalide/file/misc/magic.mgc, 102: Warning: offset `METADATA
> /usr/share/file/misc/magic.mgc, 103: Warning: offset `' invalid
> /usr/share/file/misc/magic.mgc, 106: Warning: offset `' invalid
> ' invalide/file/misc/magic.mgc, 108: Warning: offset `MozFASL
> /usr/share/file/misc/magic.mgc, 109: Warning: offset `' invalid
> /usr/share/file/misc/magic.mgc, 111: Warning: offset `' invalid
> /usr/share/file/misc/magic.mgc, 112: Warning: offset `' invalid
> /usr/share/file/misc/magic.mgc, 125: Warning: offset ` REMARK' invalid
> /usr/share/file/misc/magic.mgc, 126: Warning: offset `' invalid
> ' invalide/file/misc/magic.mgc, 127: Warning: offset `TypeLib
> /usr/share/file/misc/magic.mgc, 128: Warning: offset `' invalid
> /usr/share/file/misc/magic.mgc, 129: Warning: offset `' invalid

Looks like the linked libmagic is incompatible anyway with the
provided file.

> If possible please try to reproduce with a newer version.
[...]
> Your best next step is to pin down the exact location of the 
> crash with a debugger (either live or with a core file).
> Is SVN crashing or is libmagic crashing?

I'll keep that in mind, but have very limited time currently for
further research. No idea where to get symbol files from and stuff
like that...

> (gdb) run add /tmp/svn_crash/test.txt
> Starting program: /volume1/@entware-ng/opt/bin/svn add /tmp/svn_crash/test.txt
> warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
>
> Program received signal SIGABRT, Aborted.
> 0x00007ffff3d240f8 in raise () from /opt/lib/libc.so.6
> (gdb) bt
> #0  0x00007ffff3d240f8 in raise () from /opt/lib/libc.so.6
> #1  0x00007ffff3d2552a in abort () from /opt/lib/libc.so.6
> #2  0x00007ffff4711dd5 in ?? () from /opt/lib/libmagic.so.1
> #3  0x00007ffff4716000 in ?? () from /opt/lib/libmagic.so.1
> #4  0x00007ffff5c652ed in svn_magic.init () from /opt/lib/libsvn_subr-1.so.0
> #5  0x00007ffff7b83600 in svn_client_add5 () from /opt/lib/libsvn_client-1.so.0
> #6  0x00000000004077af in ?? ()
> #7  0x000000000041c39a in ?? ()
> #8  0x00000000004075b3 in ?? ()
> #9  0x00007ffff3d11711 in __libc_start_main () from /opt/lib/libc.so.6
> #10 0x0000000000407629 in ?? ()

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: "svn add" crashes in case of missing magic.mgc

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Jul 08, 2019 at 05:51:20PM +0200, Thorsten Schöning wrote:
> Hi all,
> 
> I recently set up a new Synology NAs and tried to version some custom
> scripts. While some SVN client was already available and checking out
> an empty directory worked as expected, adding some file to the working
> copy didn't. There wasn't any error by default, it seemed that adding
> was successful, but it wasn't, instead the working copy was locked.
> 
> > svn add dasikomp_buero_hm
> > svn st
> 
> >   L     .
> > ?       @eaDir
> > ?       dasikomp_buero_hm
> [...]
> 
> Explicitly asking for the last error showed the problem:
> 
> > svn add %f && echo $@
> > sh: line 1: 20166 Aborted                 (core dumped) svn add "test.txt"
> 
> Making strace available[1] lead to the root cause being the file
> magic.mgc not found in usual places:
> 
> > strace svn add %f
> [...]
> > stat("/root/.magic.mgc", 0x7fff5f129370) = -1 ENOENT (No such file or directory)
> > stat("/root/.magic", 0x7fff5f129370)    = -1 ENOENT (No such file or directory)
> > access("/opt/share/misc/magic.mime.mgc", R_OK) = -1 ENOENT (No such file or directory)
> > open("/opt/share/misc/magic.mgc", O_RDONLY) = -1 ENOENT (No such file or directory)
> > rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
> > tgkill(21192, 21192, SIGABRT)           = 0
> > --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=21192, si_uid=0} ---
> 
> Instead, the file was placed in the following path, which is a symlink
> only as well:
> 
> > /usr/share/file/misc/magic.mgc -> /var/packages/DiagnosisTool/target/usr/share/file/misc/magic.mgc
> 
> The link target is part of DiagnosisTools, which is interesting
> because that's exactly what has been installed using [1] to make
> strace available. Without that package I didn't find any other
> suitable file on the NAS.
> 
> Some things coming into my mind:
> 
> 1. Should "svn add" really crash silently?

No, of course it should not ;)

> 2. Should the symlink be recognized and tried like the other pathes?
> 3. Is path handling even something SVN cares about on it's own vs.
>    libmagic or else?

I believe this is handled internally by libmagic. SVN has no
idea where the magic database file is and how it gets loaded.

SVN only calls the magic_open() function provided by libmagic.
It checks the return value and skips mime-type detection via
libmagic if an error occurs. I believe that, at the time, this
code was tested with and without a magic database file and both
cases worked. But I don't think we have regression tests for this...

> The installed SVN-client:
> 
> > svn, version 1.9.7 (r1800392)
> >    compiled Jan 11 2018, 08:42:15 on x86_64-openwrt-linux-gnu
> 
> Is that worth filing a bug or fixed or known or ...? Thanks!

If possible please try to reproduce with a newer version.
However, this code hasn't been changed in years so I doubt you
will see different behaviour.

Your best next step is to pin down the exact location of the 
crash with a debugger (either live or with a core file).
Is SVN crashing or is libmagic crashing?

Thanks,
Stefan