Skip to content

Commit

Permalink
feat: enable backtraces by default
Browse files Browse the repository at this point in the history
This is a great help in debugging, and I don't think there's much
downside to doing that? Capturing a backtrace is somewhat costly,
especially on windows, but given that we run with panic=abort, that's
bound to be a pretty cold path anyways!

To disable backtraces, set `RUST_BACKTRACE=0` env variable.
  • Loading branch information
matklad committed Sep 6, 2022
1 parent 8bcbf27 commit 1ba6b34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
Instead of it aggregate `near_peer_message_received_by_type_total` metric
instead. For example, to get total rate of received messages use
`sum(rate(near_peer_message_received_by_type_total{...}[5m]))`.
* Backtraces on panics are enabled by default, so you no longer need to set
`RUST_BACKTRACE=1` environmental variable. To disable backtraces, set
`RUST_BACKTRACE=0`.

## 1.28.0 [2022-07-27]

Expand Down
11 changes: 8 additions & 3 deletions neard/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod cli;
mod log_config_watcher;

use near_primitives::version::{Version, PROTOCOL_VERSION};
use near_store::version::DB_VERSION;

use self::cli::NeardCmd;
use crate::cli::RunError;
use near_primitives::version::{Version, PROTOCOL_VERSION};
use near_store::version::DB_VERSION;
use nearcore::get_default_home;
use once_cell::sync::Lazy;
use std::env;
use std::path::PathBuf;
use std::time::Duration;

Expand Down Expand Up @@ -42,6 +42,11 @@ static ALLOC: near_rust_allocator_proxy::ProxyAllocator<tikv_jemallocator::Jemal
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

fn main() -> Result<(), RunError> {
if env::var("RUST_BACKTRACE").is_err() {
// Enable backtraces on panics by default.
env::set_var("RUST_BACKTRACE", "1");
}

rayon::ThreadPoolBuilder::new()
.stack_size(8 * 1024 * 1024)
.build_global()
Expand Down

0 comments on commit 1ba6b34

Please sign in to comment.