Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: clean TorGuard exception handling (Not Tested) #49

Merged
merged 1 commit into from
Nov 14, 2022

Conversation

parhamsaremi
Copy link

@parhamsaremi parhamsaremi commented Nov 9, 2022

Move TorGuard exception handling to a new module so that every time we want to handle a new type of exception, we
won't be bothered by adding a lot of try/except expressions.
This code is necessary for fixing [1].

Fixes #45
[1] nblockchain/geewallet#184

@parhamsaremi parhamsaremi changed the title Network: clean TorGuard exception handling Network: clean TorGuard exception handling (Not Tested) Nov 9, 2022
@knocte knocte requested a review from aarani November 14, 2022 01:11
NOnion/Network/TorGuard.fs Outdated Show resolved Hide resolved
NOnion/Network/TorGuard.fs Outdated Show resolved Hide resolved
@aarani
Copy link
Collaborator

aarani commented Nov 14, 2022

Is this all the places we do try-with in TorGuard?

@parhamsaremi
Copy link
Author

Is this all the places we do try-with in TorGuard?

Nope, There was another try but it wasn't with the same behavior https://github.com/parhamsaremi/NOnion/blob/geewallet-issue-184/NOnion/Network/TorGuard.fs#L332

@knocte
Copy link
Member

knocte commented Nov 14, 2022

https://github.com/parhamsaremi/NOnion/blob/geewallet-issue-184/NOnion/Network/TorGuard.fs#L332

WTF that's a generic catch, let's remove it in a 2nd commit (after removing it, we might get some crashes; but thanks to getting them, we'll be able to bring a more specific try-block later.

@parhamsaremi
Copy link
Author

https://github.com/parhamsaremi/NOnion/blob/geewallet-issue-184/NOnion/Network/TorGuard.fs#L332

WTF that's a generic catch, let's remove it in a 2nd commit (after removing it, we might get some crashes; but thanks to getting them, we'll be able to bring a more specific try-block later.

Sounds good. I'll work on this after addressing the previous typos (which won't take long).

Move TorGuard exception handling to a new module so that
every time we want to handle a new type of exception, we
won't be bothered by adding a lot of try/except expressions.
This code is necessary for fixing [1].

Fixes nblockchain#45
[1] nblockchain/geewallet#184
@aarani
Copy link
Collaborator

aarani commented Nov 14, 2022

https://github.com/parhamsaremi/NOnion/blob/geewallet-issue-184/NOnion/Network/TorGuard.fs#L332

WTF that's a generic catch, let's remove it in a 2nd commit (after removing it, we might get some crashes; but thanks to getting them, we'll be able to bring a more specific try-block later.

Technically, I had a reason for putting a generic catch there.
At the time, any crash there would kill the listening thread without any notice to the end user which was not ideal,
I preferred swallowing exceptions.
Currently, since I added self.KillChildCircuits() the guard announces death to all circuits if a single exception happen so it doesn't matter if the listening thread dies.

we might get some crashes

you won't. exceptions there won't be raised. only exception you might get is CircuitDestroyed-like exceptions when guard dies.

@aarani
Copy link
Collaborator

aarani commented Nov 14, 2022

https://github.com/parhamsaremi/NOnion/blob/geewallet-issue-184/NOnion/Network/TorGuard.fs#L332

WTF that's a generic catch, let's remove it in a 2nd commit (after removing it, we might get some crashes; but thanks to getting them, we'll be able to bring a more specific try-block later.

Technically, I had a reason for putting a generic catch there. At the time, any crash there would kill the listening thread without any notice to the end user which was not ideal, I preferred swallowing exceptions. Currently, since I added self.KillChildCircuits() the guard announces death to all circuits if a single exception happen so it doesn't matter if the listening thread dies.

we might get some crashes

you won't. exceptions there won't be raised. only exception you might get is CircuitDestroyed-like exceptions when guard dies.

What I'm most afraid is that I remember getting ObjectDisposedExceptions (I'm not sure if it was here) which I do not like being raised because you can just swallow them (as far as the listening thread cares).

@aarani
Copy link
Collaborator

aarani commented Nov 14, 2022

Huh! I have a comment about this:

    // Some circuit handlers send data, which by itself might try to use the stream

    // after it's already disposed, so we need to be able to handle cancellation during cell handling as well

@aarani
Copy link
Collaborator

aarani commented Nov 14, 2022

TL/DR: Personally, I prefer keeping that generic catch there.

@knocte knocte merged commit 258ab3d into nblockchain:master Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception not caught (should be re-thrown as NOnionException?) caused a crash
3 participants