Commit Graph

2411 Commits

Author SHA1 Message Date
Nick Mathewson 8effe24855 Merge branch 'error-poc' into 'main'
New error handling proof of concept

See merge request tpo/core/arti!262
2022-02-04 19:14:10 +00:00
Nick Mathewson f973fe5060 Require backtrace 0.3.8.
This is the first version that builds correctly on our CI.  It's
from back in 2018, so requiring it shouldn't cause any major
problems.
2022-02-04 13:52:46 -05:00
Nick Mathewson d594254f58 Merge branch 'fix-links' into 'main'
Properly linkify two doc comment xrefs to issues

See merge request tpo/core/arti!290
2022-02-04 16:26:51 +00:00
Ian Jackson a49889f116 Properly linkify two doc comment xrefs to issues
Fixes these messages:

  warning: this URL is not a hyperlink
   --> crates/arti/src/watch_cfg.rs:115:5
    |
115 | /// https://github.com/notify-rs/notify/issues/165 and
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com/notify-rs/notify/issues/165>`
    |
    = note: `#[warn(rustdoc::bare_urls)]` on by default
    = note: bare URLs are not automatically turned into clickable links

warning: this URL is not a hyperlink
   --> crates/arti/src/watch_cfg.rs:116:5
    |
116 | /// https://github.com/notify-rs/notify/pull/166 .
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com/notify-rs/notify/pull/166>`
    |
    = note: bare URLs are not automatically turned into clickable links
2022-02-04 15:11:44 +00:00
Ian Jackson 6c2f9dac16 channel errors: Include what we were doing 2022-02-04 15:03:19 +00:00
Ian Jackson 5b54d3e08e errors: Add some TODOs as per discussion comments 2022-02-04 14:52:30 +00:00
Ian Jackson 87270415f0 errors: ErrorKind::TODO: Fix typo in message
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772816
2022-02-04 14:46:35 +00:00
Ian Jackson ca960df6b1 errors: Change docs for ErrorKind to refer to Arti
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772810
2022-02-04 14:43:58 +00:00
Ian Jackson f5e874cf91 errors: Drop "Error" and "Failed" from various enum variants 2022-02-04 14:42:37 +00:00
Ian Jackson 0462533863 Box the Error in a TorError
This will get quite large and boxing it here is very convenient.

This also avoids us exposing a large error type to our callers.
2022-02-04 14:42:37 +00:00
Ian Jackson 43fc900284 errors: Handle exit circuit creation failure the new way 2022-02-04 14:42:37 +00:00
Ian Jackson b3cebf163f errors: Handle circmgr setup errors differently
The motivation for doing this now is to remove the `#[from]` so we
would spot where operationsl circuit setup failures were handled.
(But it turns out that they are turned into internal errors!)

Perhaps this will want to become a different error type from circmgr
in due course, but for now we simply use a bespoke variant of
TorError.

It will want its own Kind.  The TODO in the HasKind impl marks
this (amongst much else here).
2022-02-04 14:42:37 +00:00
Ian Jackson d21b2cc6f5 tor-circmgr: Introduce TargetPorts with a pretty Display impl 2022-02-04 14:42:37 +00:00
Ian Jackson 09116d7b4d tor-circmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson f4813e249c tor-circmgr: Handle channel creation errors in the new style 2022-02-04 14:42:37 +00:00
Ian Jackson 0a1cda6886 tor-chanmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson 2a471ffd1a tor-chanmgr: Handle IO errora in the new style
Two ? in the tests become expects, which will do.  That avoids having
to construct a proper error with context here.
2022-02-04 14:42:37 +00:00
Ian Jackson 2101dd5e39 errors: Introduce error_detail feature
Right now we must always expose the `Error` type since we haven't
converted everything.
2022-02-04 14:42:37 +00:00
Ian Jackson 9a293a1f6f errors: Refer to err::Error in some bits of arti_client
We are going to make the top-level Error type conditionally hidden.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e577f9a17 errors: Introduce TorError
Still much to do here.
2022-02-04 14:42:37 +00:00
Ian Jackson 14f67609f7 errors: Initial impl HasKind in arti-client, ErrorKind::TODO
This involves making a temporary ErrorKind::TODO.  That will continue
to exist until all errors (at least, the ones that make it out to
here) can be properly categorised.

Introducing this will let us work from the top and bottom towards the
middle.
2022-02-04 14:42:37 +00:00
Ian Jackson bdd58bb6b7 errors: impl HasKind for GuardMgrError 2022-02-04 14:42:37 +00:00
Ian Jackson a779c1f1dd spawn errors: tor-guardmgr: Use formulaic pattern
This makes this like all the others, and is marginally shorter
2022-02-04 14:42:37 +00:00
Ian Jackson 2f1d98403b spawn errors: Fix tor-dirmgr 2022-02-04 14:42:37 +00:00
Ian Jackson de17c64412 spawn errors: Fix arti-client, tor-chanmgr, tor-circmgr
Provide an enum variant to contain the SpawnError and a From impl.

We use `#[from]` here because it doesn't really make sense to attach
any context, as it's not likely to be very relevant.
2022-02-04 14:42:37 +00:00
Ian Jackson 68d0ec437f spawn errors: impl HasKind for futures::SpawnError
This needs two kinds.  We have decided to treat a non-shutdown
SpawnError as "unexplained" rather than as an InternalError.

There are many crates whose
  From<futures::task::SpawnError> for Error
erroneously treat it as an internal error.  We will fix them in a moment.
2022-02-04 14:42:37 +00:00
Ian Jackson a623982197 tor_persist::Error: impl HasKind and adjust comments
And change the comments to slightly reinterpret these errors, to
relate to the circumstances rather than error generation site.
2022-02-04 14:42:37 +00:00
Ian Jackson 6e1dc612cc tor-error: Add as a ddpendency to many crates
Doing this here makes it easier when I rebase/reorder things
2022-02-04 14:42:37 +00:00
Ian Jackson 89b0c108d7 tor-error: provide into_internal! 2022-02-04 14:42:37 +00:00
Ian Jackson 776270fee2 tor-error: Allow making an `InternalError` from some other error
This can be used in call sites where an error is thought not to be
possible.

The `source` will be used only for formatting messages.
2022-02-04 14:42:37 +00:00
Ian Jackson c963bd648b tor-error: Introduce InternalError as a type and a kind
This can contain a backtrace, which will be printed.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e5b6fa820 tor-error: Skeleton for new crate
As per doc/Errors.md.

Currently there are no error kinds.  Some will be added as we go along.
2022-02-04 14:33:09 +00:00
Ian Jackson a4765717da tor-persist: Distinguish load vs. store json errors
Serialisation errors ought not to occur, since they would represent an
attempt to store malformed data, or something.  (We always convert to
a string, so the JSON error never contains IO errors or the like.)

Deserialisation errors mean the persistent state is corrupt.
2022-02-04 14:33:09 +00:00
Ian Jackson 235cd254ca docs/Errors.md: Say where error type is printed 2022-02-04 14:33:09 +00:00
Ian Jackson 06ce4bba1e docs/Errors.md: Say put context in caller's error (not calllee's) 2022-02-04 14:33:09 +00:00
Ian Jackson a7e6caa731 tor-circmgr: impl Display for TargetPort
This will be used for error handling, and perhaps other things.
2022-02-04 14:33:09 +00:00
Ian Jackson 5edd031b97 tor-linkspec: impl Display for OwnedChanTarget and OwnedCircTarget 2022-02-04 14:33:09 +00:00
Ian Jackson eaa449d373 tor-circmgr: Turn a type annotation comment into code
The type annotation may not be necessary for inference, but as a
comment it risks becoming false.  So it should be uncommented, or
deleted.

Error types round here are not entirely trivial so uncomment it.
2022-02-04 14:33:09 +00:00
eta 4413645c1b Merge branch 'eta/arti-bench-ci' into 'main'
arti-bench: run the benchmarks in CI, and keep the results

See merge request tpo/core/arti!283
2022-02-03 20:35:27 +00:00
eta 05046626f3 arti-bench: run the benchmarks in CI, and keep the results
This adds `arti-bench` to the `integration` job in the CI pipelines, and
keeps around the JSON benchmark output for later comparison.
2022-02-03 18:31:32 +00:00
Ian Jackson bb78e87dc8 Merge branch 'add-better-shellcheck' into 'main'
Remove file ending of shellcheck_all and downgrade_dependencies script

See merge request tpo/core/arti!278
2022-02-03 18:14:58 +00:00
Daniel Schischkin 4509f8b9d4 Remove file ending of shellcheck_all and downgrade_dependencies script 2022-02-03 18:14:57 +00:00
Nick Mathewson e332aa2716 Merge branch 'ticket270' into 'main'
Watch configuration files and reload them when they change

Closes #270

See merge request tpo/core/arti!280
2022-02-03 16:56:37 +00:00
eta e9087e1fed Merge branch 'eta/reactor-2.5' into 'main'
Fix severe reactor ordering problems

See merge request tpo/core/arti!282
2022-02-03 16:27:57 +00:00
Nick Mathewson 49431f5442 Document that `notify` behavior is strange with symlinks
(More specifically, `notify` behaves differently on different
platforms.  On some, it can watch specific directory objects on the
filesystem, and so it only notices when _those_ directories change.
If you change a symlink so that the canonical configuration file
location is now in some other directory, `notify` won't notice.  But
on other platforms, notify just does "stat()" in a loop. On those,
it _will_ notice if the configuration file changes.)
2022-02-03 11:11:21 -05:00
Nick Mathewson 73bb6f342e Merge branch 'add-final-newline-force' into 'main'
Add editorconfig to force some rules (Final Newline)

See merge request tpo/core/arti!289
2022-02-03 15:27:13 +00:00
Daniel Schischkin 3a7412f4cf Add editorconfig to force some rules (Final Newline) 2022-02-03 15:27:13 +00:00
Nick Mathewson 03755a5c7b Merge branch 'dirclient-testing' into 'main'
dir-client: bug fix and more tests

See merge request tpo/core/arti!271
2022-02-03 15:09:06 +00:00
eta 24d12163f2 Fix severe reactor ordering problems
A number of severe problems with the circuit reactor were fixed which
could cause reordering of cells (which causes relays to terminate the
circuit with a protocol violation, as they become unable to decrypt
them). These mostly revolve around improper usage of queues:

- The code assumed that a failure to place cells onto the channel would
  persist for the duration of a reactor cycle run. However, under high
  contention, this wouldn't always be the case.
  - This leads to some cells getting enqueued while others go straight
    through, before the enqueued cells.
  - To fix this, we block sending cells out of the channel while there
    are still some enqueued.
- The hop-specific queues queued after encryption, not before. This was
  very brittle, and led to frequent mis-ordering.
  - This was fixed by making them not do that.

This is arti!264 / 5bce9db562 without the
refactor part.
2022-02-03 15:04:28 +00:00
Nick Mathewson 656ad08d65 Avoid a potential infinite loop in configuration-watching
Since the user can put their logfiles and configuration files in the
same directory, writing to the log can trigger an event from
`notify`.  If we log every non-interesting event from `notify`, then
we'll trigger the logs every time we log, and fill up the disk.

This commit removes the offending log and adds a comment about why.
If we someday decide we do need to log here, maybe we can rate-limit
the messages or something.
2022-02-03 09:38:58 -05:00