abraunegg / onedrive

OneDrive Client for Linux
https://abraunegg.github.io
GNU General Public License v3.0
9.97k stars 859 forks source link

Fix Aborted in monitor mode on interrupt #2725

Closed JC-comp closed 1 month ago

JC-comp commented 4 months ago

This PR resolves the error Aborting from core/sync/mutex.d(149) Error: pthread_mutex_destroy failed.Aborted on interruption in monitor mode. (https://github.com/abraunegg/onedrive/discussions/2710#discussioncomment-9559497)

Changes

  1. Two stage interruption to resume threads before force exiting
  2. Ensure the cleanup process executes only once.
JC-comp commented 4 months ago

@abraunegg Please also provide me with the reproduction steps if there are any segfaults introduced by the PRs removed in #2724.

abraunegg commented 4 months ago

@JC-comp Thanks for investigating. PR #2724 was just a PR to try and separate out what could be causing the issue.

Over the last few days I have also been back tracking all the changes with log.d - basically doing a complete review there as well, but also something really interesting is falling out of the analysis:

  1. Using the distribution version of LDC - the segfault(s) can be triggered
  2. Using the LDC provided install, such as curl -fsS https://dlang.org/install.sh | bash -s ldc-1.30.0 for Debian 12 - the different segfaults do not occur .......

Right now I am going to pause this PR - finish my investigations with LDC package | LDC install and reviewing log.d / logging in general and see if I can resolve the other segfaults you identified in #2724 ... then I will work forwards from there.

JC-comp commented 4 months ago

@abraunegg One of the differences I found between the two versions that trigger the segfaults is related to the implementation of the exit function. The distribution version calls the destructor on exit (which is unexpected) and triggers the segfault when recycling some resources in the destructor. However, the version from the installation script exits directly without recycling, thereby not triggering the segfaults.

Here is an example to illustrate the difference:

import core.stdc.stdlib: EXIT_SUCCESS, exit;
import std.stdio;

class A {
    ~this () { writeln("destructor called"); }
};

int main() {
    A a = new A;
    exit(EXIT_SUCCESS);
    return 0;
};
abraunegg commented 1 month ago

No longer required, replaced by #2767

abraunegg commented 1 month ago

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.