Infomaniak / desktop-kDrive

:computer: Desktop Syncing Client for kDrive
GNU General Public License v3.0
28 stars 5 forks source link

Fix vfs socket bug. #234

Closed herve-er closed 2 months ago

herve-er commented 3 months ago

Summary: Fix issue with random crashes during app download step related to QLocalSocket internal buffer management.

Description: We have identified an issue where the application crashes randomly during the download step, initially thought to be related to large sync operations.

Upon investigation, the error occurs within the vfsForceStatus call, specifically when the socket->write method is invoked within SocketListener::sendMessage. The root cause appears to be inconsistencies in the QLocalSocket's internal buffer, which occasionally becomes empty or changes size unpredictably.

During downloads, the write method is called in a dedicated thread, while some QLocalSocket private callback rely on connect and are handled by the event loop (in the main thread). This asynchronous handling can lead to a situation where one download callback interferes with another, corrupting the download buffer.

Solution: To mitigate this issue, we propose emitting a signal from the download thread instead of directly invoking the function. This approach ensures that all operations are processed sequentially by the application's event loop in the main thread, preventing interference between multiple download instances and other file explorer events.

ChristopheLarchier commented 3 months ago

I'm not a fan of this solution (Qt signal in AppServer). My proposition: https://github.com/Infomaniak/desktop-kDrive/pull/236

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud