Walletwasabi: TorProcessManager not stopping properly

Created on 30 Nov 2019  路  14Comments  路  Source: zkSNACKs/WalletWasabi

After closing my wasabi, the process never stopped because TorProcessManager:

 INFO        WalletService (705)     Local Bitcoin Core node disconnected.
 INFO        Global (608)    WalletService is stopped.
 INFO        TorProcessManager (292) Tor did not work properly for 9 seconds. Maybe it crashed. Attempting to start it...
 INFO        TorProcessManager (66)  Tor is already running.
 INFO        TorProcessManager (292) Tor did not work properly for 26 seconds. Maybe it crashed. Attempting to start it...
 INFO        TorProcessManager (66)  Tor is already running.

Then I tried to CTRL+C wasabi, and close tor manually:

WARNING     Global (186)    Process was signaled for killing.
Warning     Global (186)    Process was signaled for killing.
Warning     Global (186)    Process was signaled for killing.
Warning     Global (186)    Process was signaled for killing.
Warning     Global (186)    Process was signaled for killing.
Warning     Global (186)    Process was signaled for killing.
Info        TorProcessManager (292) Tor did not work properly for 147 seconds. Maybe it crashed. Attempting to start it...
Info        TorProcessManager (66)  Tor is already running.
Info        TorProcessManager (292) Tor did not work properly for 165 seconds. Maybe it crashed. Attempting to start it...
Info        TorProcessManager (107) Tor instance found at C:\Users\NicolasDorier\AppData\Roaming\WalletWasabi\Client\tor\Tor\tor.exe.
Info        TorProcessManager (128) Starting Tor process with Process.Start.
Info        TorProcessManager (144) Tor is running.
Info        TorProcessManager (292) Tor did not work properly for 182 seconds. Maybe it crashed. Attempting to start it...
Info        TorProcessManager (66)  Tor is already running.
debug

All 14 comments

We made a lot of refactorings there, I haven't noticed this behavior for a long time.

I just tried on latest release:

2020-09-19 22:47:23 WARNING     Global (168)    Process was signaled for killing.
2020-09-19 22:47:23 WARNING     Global (647)    Process is exiting.
2020-09-19 22:47:23 INFO        WalletManager (356)     KeyManager backup saved to `C:\Users\NicolasDorier\AppData\Roaming\WalletWasabi\Client\WalletBackups\Wallet1.json`.
2020-09-19 22:47:23 INFO        Wallet (276)    ChaumianClient is stopped.
2020-09-19 22:47:23 INFO        WalletManager (358)     Wallet is stopped.
2020-09-19 22:47:23 INFO        Global (699)    Disposed FeeProviders.
2020-09-19 22:47:23 INFO        Global (706)    CoinJoinProcessor is disposed.
2020-09-19 22:47:23 INFO        Global (713)    Synchronizer is stopped.
2020-09-19 22:47:23 INFO        MainWindow.xaml (109)   UiConfig is saved.
2020-09-19 22:47:23 INFO        HostedServices (80)     Stopped Software Update Checker.
2020-09-19 22:47:23 INFO        HostedServices (130)    Disposed Software Update Checker.
2020-09-19 22:47:23 INFO        Global (722)    Stopped background services.
2020-09-19 22:47:23 INFO        Global (733)    AddressManager is saved to `C:\Users\NicolasDorier\AppData\Roaming\WalletWasabi\Client\AddressManager\AddressManagerMain.dat`.
2020-09-19 22:47:23 INFO        Global (746)    Nodes are disposed.
2020-09-19 22:47:23 INFO        Global (771)    TorManager is stopped.
2020-09-19 22:47:23 INFO        Global (794)    AsyncMutex(es) are stopped.
2020-09-19 22:47:23 INFO        Global (810)    Wasabi stopped gracefully (b359db3b-fe8d-4b2b-86e3-a3138716d4b6).
2020-09-19 22:47:23 INFO        Program (151)   Wasabi GUI stopped gracefully (b359db3b-fe8d-4b2b-86e3-a3138716d4b6).

And the program never quit. I don't know if that's the TorProcessManager this time, but there is still something blocking.

Is this when debugging?

  • I noticed that sometimes it needs 30 secs to be done, especially when you use core integration.
  • When debugging and click into the terminal the console messages so the Console.Writelines. You can make it continue by pressing an enter in the terminal.

not when debugging, I run dotnet run -c Release

@molnard if #4456 is the reason, it means that somewhere in the code there is a .Result or GetAwaiter().GetResult()

@molnard @kiminuo but not having .ConfigureAwait(false) in code that is not a library is normal.

While adding blindly .ConfigurationAwait(false) everywhere, in the expectation you don't miss any of them, will work, a better solution would be to pinpoint where somebody is calling .GetResult() or .Result on a task and replace by a async/await.
I thik there is some roslyn source analyser to find that.

@kiminuo but not having .ConfigureAwait(false) in code that is not a library is normal.

I don't believe too much it will be solved by that. Even though sometimes it leads to unexpected outcomes.

a better solution would be to pinpoint where somebody is calling .GetResult() or .Result on a task and replace by a async/await.

Some recent commits did exactly that:

It's an ongoing process.

I thik there is some roslyn source analyser to find that.

Do you really need a Roslyn source code analyzer for that? .GetAwaiter().GetResult() can be quite easily found.

It would be useful to test latest master version, if the issue is still present for you.

In theory and according to the source code by itself, it should quit. The execution hits the last line of code. However, there is clearly something that is blocking the termination of the process. The analyzer is a good idea, but it is not happening for me.
Adding .ConfigureAwait(false) to every library method does not hurt - I agree that is not a final solution as it still can get into a deadlock.

Small refactorings are the way to go that will guarantee the termination of the tasks.

Then it means there is some foreground thread not properly exited.

Yes, I guess or a task.

@molnard What about logging (debug level) all running threads when Wasabi is exiting? I'm not sure whether this make sense in C# but in Java, I have once used it to my advantage to find out the lingering thread.

This has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yahiheb picture yahiheb  路  3Comments

MaxHillebrand picture MaxHillebrand  路  3Comments

yahiheb picture yahiheb  路  3Comments

UkolovaOlga picture UkolovaOlga  路  3Comments

kenny47 picture kenny47  路  3Comments