You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
root on symlinked path causes panic when using "Watch for changes" #5043
I have a "storage" folder symlinked to mnt: /home/piotr/storage -> /mnt/storage/storage/
This causes panic when using the notify backend
panic: bug: Notify backend is processing a change outside of the filesystem root: root==/home/piotr/storage/synced/oneplus5/, rootSymEval==/home/piotr/storage/synced/oneplus5/, path==/mnt/storage/storage/synced/oneplus5/.stfolder
Version Information
Syncthing Version: v0.14.48
OS Version: Linux 64 Ubuntu 16.04 (installed from apt)
Browser Version: (if applicable, for GUI issues)
Why asserting/panicing is a good question - it makes life easy for me as I don't need to think about how to handle a case that should never happen. A panic is ideal for that, as one line of code guarantees that the issue will come to my attention if it ever arises. Obviously, it's not quite user-friendly. All of that is tangential to your actual case though.
What needs figuring out is where the evaluation of symlinks in your filesystem instance failed, i.e. why there is this conflict:
panic: bug: Notify backend is processing a change outside of the filesystem root: root==/home/piotr/storage/synced/oneplus5/, rootSymEval==/home/piotr/storage/synced/oneplus5/, path==/mnt/storage/storage/synced/oneplus5/.stfolder
The point of rootSymEval is exactly to resolve this issue, i.e. it should be the evaluated symlink as returned by filepath.EvalSymlinks und thus the same. Please run the gist and report the results.
Same panic happening here, setup similar to larroy's:
/oldssd/jamieson/ $ ls -l /home/
lrwxrwxrwx 1 root root 17 Feb 6 21:36 jamieson -> /oldssd/jamieson/
Basically ran out of space on one of my SSD's, so just symlinked from another one with free space available. Reproduce: just add a new user and then symlink the home directory from somewhere else.
Panic at 2018-08-06T15:47:05-05:00
panic: bug: Notify backend is processing a change outside of the filesystem root:
root==/home/jamieson/Essential-Ph1-Camera/,
rootSymEval==/home/jamieson/Essential-Ph1-Camera/,
path==/oldssd/jamieson/Essential-Ph1-Camera/.stfolder
(Also, I was also getting a panic regarding "panic: cannot start already running folder", but that stopped once I disabled Auto-Accept and created that folder manually, with the same id: see also #5063 )
If I pause the folder that I'm getting running folder error on (from the same device) instead of disabling Auto-Accept, then I get this nice little issue (this is still running stock v0.14.49 on Arch):
[SGBHH] 09:52:17 INFO: Auto-accepted abcdef1234 folder "Ph1" (abc123) at path ~/Ph1
[SGBHH] 09:52:17 INFO: Connection to XXX at [yyy]:58648-[zzz]:22000/tcp-client closed: <nil>
panic: runtime error: invalid memory address or nil pointer dereference
(I can email you the full uncensored panic if you like.)
Just a hunch: these two issues (#5063 and this one, #5043) might be related to each other, especially when symlinks are thrown into the mix.
Maybe you need to login somehow to teamcity before the link can be accessed.
And yes, I'd be interested in the panic trace. The trace shouldn't contain any personal information, but you can email it to me if you like. It might be related, but in that case it was a "folder already running" panic, not a nil deref.
N.B., this running folder issue is a different folder than the original camera folder shared from device; disabling auto accept got that original folder working, and I haven't been able to reproduce that issue until this new one popped up.
Great. Yes, that one was fixed as soon as I turned off auto-accept and restarted on both sides. Ph1 is a new one to try to force reproduction of this issue again, but I haven't gotten it to trigger the same symlink issue. (The directory wasn't created on the desktop side, so it still doesn't exist.)
I still don't understand what exactly is happening, but regardless the way symlinks in the root path are handled today is clearly bad and may lead to panics. Therefore I proposed a change that probably will fix this issue: #5105
The nil deref trace from #5043 (comment) turned out to be less obvious than I thought initially, it's actually very confusing. If you do have the full trace and logs leading to it, I would be very interested to get them (by email or in the forum please, as it's not related to this issue).
Activity
imsodin commentedon Jul 1, 2018
Can you run the following script on your system and report the results, i.e. install Go and run
go run test.goIn any case we need to act on, not just ignore an error when determining the root with symlinks evaluated: https://github.com/syncthing/syncthing/blob/master/lib/fs/basicfs.go#L56
Either panic already there (probably a bad idea, though I don't get why it should ever fail), or disable watching to prevent panics.
larroy commentedon Jul 6, 2018
larroy commentedon Jul 6, 2018
Why the assertion in the first place? what are we trying to accomplish in unrootedChecked ?
imsodin commentedon Jul 6, 2018
@larroy
Why asserting/panicing is a good question - it makes life easy for me as I don't need to think about how to handle a case that should never happen. A panic is ideal for that, as one line of code guarantees that the issue will come to my attention if it ever arises. Obviously, it's not quite user-friendly. All of that is tangential to your actual case though.
What needs figuring out is where the evaluation of symlinks in your filesystem instance failed, i.e. why there is this conflict:
panic: bug: Notify backend is processing a change outside of the filesystem root: root==/home/piotr/storage/synced/oneplus5/, rootSymEval==/home/piotr/storage/synced/oneplus5/, path==/mnt/storage/storage/synced/oneplus5/.stfolder
fmt.Println(filepath.EvalSymlinks("/home/piotr/storage/synced/oneplus5/"))
/mnt/storage/storage/synced/oneplus5
I can't reproduce this issue, so a bit of back and forth will be necessary (maybe I am also just missing the obvious). Can you check what's the path for your folder in config.xml and then adjust the path at the bottom of the following gist and run it (it's basically the relevant syncthing code with lots of verbosity):
https://gist.github.com/imsodin/b8ec2ec226a0575f7619997b287e6e28
larroy commentedon Jul 6, 2018
Because the mount point is in /mnt/storage but in my home folder there's a link from ~/storage to /mnt/storage
imsodin commentedon Jul 9, 2018
The point of
rootSymEvalis exactly to resolve this issue, i.e. it should be the evaluated symlink as returned byfilepath.EvalSymlinksund thus the same. Please run the gist and report the results.perpetual-hydrofoil commentedon Aug 6, 2018
Same panic happening here, setup similar to larroy's:
/oldssd/jamieson/ $ ls -l /home/
lrwxrwxrwx 1 root root 17 Feb 6 21:36 jamieson -> /oldssd/jamieson/
Basically ran out of space on one of my SSD's, so just symlinked from another one with free space available. Reproduce: just add a new user and then symlink the home directory from somewhere else.
Here's the result of that gist:
larroy commentedon Aug 6, 2018
Sorry I haven't been able to rerun, hadn't had access to that desktop for a bit.
imsodin commentedon Aug 7, 2018
@jamiesonbecker What was the panic message in your case (I am interested in the paths)? Thanks for running the gist!
perpetual-hydrofoil commentedon Aug 7, 2018
@imsodin sure:
imsodin commentedon Aug 7, 2018
The weird thing is, that the gist (which is the exact same code with some debug statements) produces the correct result for the evaluated path
&{/home/jamieson/Essential-Ph1-Camera/ /oldssd/jamieson/Essential-Ph1-Camera/}but it's wrong in the panicrootSymEval==/home/jamieson/Essential-Ph1-Camera/,. I have no idea, the next thing I'd try is move the debug info into the Syncthing binary and test again. A version on top of master from the build servers is herehttps://build.syncthing.net/repository/download/Syncthing_BuildLinuxCross/24994:id/syncthing-linux-amd64-v0.14.50-rc.1%2B3-gf9798d8.tar.gz%21/syncthing-linux-amd64-v0.14.50-rc.1%2B3-gf9798d8/syncthing
and a version on top of 0.14.49 compile by me is here
https://polybox.ethz.ch/index.php/s/ImkcFgiqQHxkCHt
Please run either of those until you get the panic again and post the logs here.
perpetual-hydrofoil commentedon Aug 7, 2018
(Also, I was also getting a panic regarding "panic: cannot start already running folder", but that stopped once I disabled Auto-Accept and created that folder manually, with the same id: see also #5063 )
perpetual-hydrofoil commentedon Aug 7, 2018
(403 on build.syncthing URL)
Can you confirm SHA256
d8a9982d4a196d86ec0fc648f3c19860c5095852e372db176ed5ec8c69e3d7e9on your polybox link above?perpetual-hydrofoil commentedon Aug 7, 2018
If I pause the folder that I'm getting running folder error on (from the same device) instead of disabling Auto-Accept, then I get this nice little issue (this is still running stock v0.14.49 on Arch):
(I can email you the full uncensored panic if you like.)
Just a hunch: these two issues (#5063 and this one, #5043) might be related to each other, especially when symlinks are thrown into the mix.
imsodin commentedon Aug 7, 2018
@jamiesonbecker Yes, that hash is correct.
Maybe you need to login somehow to teamcity before the link can be accessed.
And yes, I'd be interested in the panic trace. The trace shouldn't contain any personal information, but you can email it to me if you like. It might be related, but in that case it was a "folder already running" panic, not a nil deref.
2 remaining items
perpetual-hydrofoil commentedon Aug 7, 2018
Resuming the problematic device and folder:
perpetual-hydrofoil commentedon Aug 7, 2018
N.B., this running folder issue is a different folder than the original camera folder shared from device; disabling auto accept got that original folder working, and I haven't been able to reproduce that issue until this new one popped up.
imsodin commentedon Aug 7, 2018
The nil deref is completely unrelated to everything else - thanks anyway for finding it ;)
The cannot start already running folder almost certainly is #5063.
Does a folder for
/oldssd/jamieson/Ph1actually exist? Because above in the gist and panic, it was/home/jamieson/Essential-Ph1-Camera/.perpetual-hydrofoil commentedon Aug 7, 2018
Great. Yes, that one was fixed as soon as I turned off auto-accept and restarted on both sides.
Ph1is a new one to try to force reproduction of this issue again, but I haven't gotten it to trigger the same symlink issue. (The directory wasn't created on the desktop side, so it still doesn't exist.)lib/fs: Evaluate root when watching not on fs creation (fixes syncthi…
imsodin commentedon Aug 8, 2018
@jamiesonbecker
I still don't understand what exactly is happening, but regardless the way symlinks in the root path are handled today is clearly bad and may lead to panics. Therefore I proposed a change that probably will fix this issue: #5105
The nil deref trace from #5043 (comment) turned out to be less obvious than I thought initially, it's actually very confusing. If you do have the full trace and logs leading to it, I would be very interested to get them (by email or in the forum please, as it's not related to this issue).
Merge remote-tracking branch 'imsodin/watchSymlink' into flaky
lib/fs: Evaluate root when watching not on fs creation (fixes #5043) (#…
Merge branch 'release'