nextcloud / nextcloud/desktop

[Bug]: nexcloud client freezes with circular symbolic links

Open
#6,746 1 comment 2 reactions 0 assignees View on GitHub
0. Needs triage
Dominant language
C++
Stars
3.9k
Forks
1k
Avg merge
1d 21h
Merged PRs (30d)
127

Description

### ⚠️ Before submitting, please verify the following: ⚠️

- [X] This is a **bug**, not a question or a configuration issue.
- [X] This issue is **not** already reported on Github (I've searched it).
- [X] Nextcloud Server and Desktop Client are **up to date**. See [Server Maintenance and Release Schedule](https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule) and [Desktop Releases](https://nextcloud.com/install/#install-clients) for supported versions.
- [X] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/)

### Bug description

Since recently, my nextcloud client freezes at startup, consuming 100% CPU for few minutes, then crashes. The problem seems to be related to circular symlinks (I mean, symlinks pointing to a parent directory of themselves). In fact, removing these symlinks makes nextcloud work fine again.

### Steps to reproduce

1. In a directory do be sync-ed (for me ~/Nextcloud), untar the attached file [BUG.TGZ](https://github.com/nextcloud/desktop/files/15284102/BUG.TGZ). This creates a folder BUG with a minimal example. It contains two symlinks, ROOT and directory/ROOT, which both point to the directory itself: BUG.
2. launch nextcloud
3. nextcloud freezes and finally crashes after consuming all memory (16Gb, see log below)

```
$ command time -v nextcloud
nextcloud.gui.application: Migrating old config from "/home/plo/.local/share/Nextcloud" to "/home/plo/.config/Nextcloud"
nextcloud.gui.application: Failed to move the old config directory to its new location ( "/home/plo/.local/share/Nextcloud" to "/home/plo/.config/Nextcloud" )
nextcloud.gui.application: Will move the individual files ("Nextcloud_sync.log")
nextcloud.gui.application: Fallback move of "Nextcloud_sync.log" also failed
Command terminated by signal 9
Command being timed: "nextcloud"
User time (seconds): 116.63
System time (seconds): 199.70
Percent of CPU this job got: 97%
Elapsed (wall clock) time (h:mm:ss or m:ss): 5:23.48
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 14325548
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 569
Minor (reclaiming a frame) page faults: 3585062
Voluntary context switches: 8733
Involuntary context switches: 14269
Swaps: 0
File system inputs: 122528
File system outputs: 84592
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
```

### Expected behavior

The behaviour of the previous version was to ignore all symlinks, so they were harmless.

Nexcloud behaves correctly after removal of these symlinks.

### Which files are affected by this bug

directory/ROOT

### Operating system

Linux

### Which version of the operating system you are running.

Ubuntu 22.04.4

### Package

Distro package manager

### Nextcloud Server version

24.0.9.2

### Nextcloud Desktop Client version

3.13.0

### Is this bug present after an update or on a fresh install?

Updated from a minor version (ex. 3.4.2 to 3.4.4)

### Are you using the Nextcloud Server Encryption module?

Encryption is Enabled

### Are you using an external user-backend?

- [X] Default internal user-backend
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other

### Nextcloud Server logs

```shell
nexcloud crashes before producing any log
```

### Additional info

Since 2019 and until now I synchronized about 10Gb in 60,000 files between 3 Ubuntu machines without any problem. The problem is quite recent for me (couple of weeks ?). Seems to be since a package update. Here are the packages I use:

```
$ apt list --installed nextcloud*
En train de lister... Fait
nextcloud-desktop-common/jammy,jammy,now 3.13.0-20240425.171743.1e5523e50-1.0~jammy1 all [installé, automatique]
nextcloud-desktop-doc/jammy,jammy,now 3.13.0-20240425.171743.1e5523e50-1.0~jammy1 all [installé]
nextcloud-desktop-l10n/jammy,jammy,now 3.13.0-20240425.171743.1e5523e50-1.0~jammy1 all [installé]
nextcloud-desktop/jammy,now 3.13.0-20240425.171743.1e5523e50-1.0~jammy1 amd64 [installé]

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the freeze by unpacking BUG.TGZ into a synced directory and launching the Nextcloud client; inspect how the client handles the circular links at directory/ROOT. Done means the client no longer exhausts memory or crashes and circular symlinks are handled as safely as in the previous version.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.