Where's the unwrap which panicked?

Got a panic from an "unwrap". But where's the "unwrap" in the source code?

03:47:21 [ERROR] =========> Panic called `Option::unwrap()` on a `None` value at file /home/john/.cargo/git/checkouts/rend3-hp-02d0af34d7a82ce7/1450746/rend3/src/managers/object.rs, line 136 in thread main.
Backtrace:
 libcommon::common::commonutils::catch_panic::{{closure}}
             at /home/john/projects/sl/SL-test-viewer/libcommon/src/common/commonutils.rs:389:25
 rend3::managers::object::ObjectManager::add
 rend3::renderer::eval::evaluate_instructions
             at /home/john/.cargo/git/checkouts/rend3-hp-02d0af34d7a82ce7/1450746/rend3/src/renderer/eval.rs:72:21
 rend3::renderer::Renderer::evaluate_instructions
             at /home/john/.cargo/git/checkouts/rend3-hp-02d0af34d7a82ce7/1450746/rend3/src/renderer/mod.rs:422:9
 <sharpview::AppUi as rend3_framework::App>::handle_redraw
             at /home/john/projects/sl/SL-test-viewer/sharpview/src/main.rs:718:31

Source is in rend3-hp/rend3/src/managers/object.rs at trunk · John-Nagle/rend3-hp · GitHub

and there's no "unwrap" near there. The line mentioned in the panic is

let mesh = &mesh_manager_guard[**mesh];

which lacks an "unwrap". There's no .unwrap() in the entire function.

But at that point the code is dropping a lock. It's a parking_lot lock. I've looked for an unwrap which might be implicitly called by an inlined function But I don't see an unwrap anywhere in the parking_lot code drop sequence.

Suggestions on how to debug this?

Notes:

  • Not my code, fork of another project no longer being maintained. But the original fails sometimes, too.
  • Failure rate is once per hours of usage.
  • This is "release" mode with the debug info, not "debug" mode. Debug mode is too slow.

I think the unwrap() happens inside the impl Index<xxx> for the mesh_manager_guard, probably this line:

1 Like

Ah, that makes sense. Thanks.

The array is from a Vec<Option<InternalMesh>>>, part of an internal storage allocator. handle.idx must be the index of a slot with value None. So this is the Rust equivalent of a dangling pointer.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.