anderslanglands / optix-rs

An oxidized wrapper around NVidia's OptiX raytracing library
15 stars 6 forks source link

Some optix7 branch examples causes segmentation faults #3

Closed oceanusxiv closed 4 years ago

oceanusxiv commented 4 years ago

Hi

I know it's still quite premature and you're certainly still working on it, but I just want to say that I tried out your examples in the optix7 branch, and it appears that aside from the first example where no optix launch calls were made, all subsequent examples that actually launches an optix kernel appears to cause a segmentation fault, here's the backtrace for 02_pipeline

#0  0x00007fffd01c56f0 in ?? () from /lib/x86_64-linux-gnu/libnvidia-rtcore.so.450.51.06
#1  0x00007fffd2fbef86 in ?? () from /lib/x86_64-linux-gnu/libnvoptix.so.1
#2  0x000055555557a0e5 in optixLaunch (pipeline=0x5555571a4bc0, stream=0x555555bb3900, pipelineParams=140736544769536, pipelineParamsSize=24, sbt=0x7fffffffd4b0, width=256, height=128, depth=1) at /mnt/work/optix-rs/optix/optix_stubs-capi/optix_stubs.c:441
#3  0x0000555555566cde in optix::launch (pipeline=0x7fffffffd4f0, stream=0x7fffffffd430, buf_launch_params=0x7fffffffd450, sbt=0x7fffffffd4b0, width=256, height=128, depth=1) at /mnt/work/optix-rs/optix/src/lib.rs:128
#4  0x000055555556d9e8 in _02_pipeline::renderer::Renderer::render (self=0x7fffffffd430) at optix/examples/02_pipeline/renderer.rs:192
#5  0x0000555555561df8 in _02_pipeline::main () at optix/examples/02_pipeline/main.rs:6
#6  0x000055555556a85b in core::ops::function::FnOnce::call_once () at /home/eric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
#7  0x00005555555618be in std::sys_common::backtrace::__rust_begin_short_backtrace (f=0x555555561d20 <_02_pipeline::main>) at /home/eric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137
#8  0x0000555555566b61 in std::rt::lang_start::{{closure}} () at /home/eric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66
#9  0x00005555555b4cf1 in core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once () at /rustc/2d8a3b9181f41d3af9b9f016c5d73b2553e344bf/library/core/src/ops/function.rs:259

I'm not entirely sure what's going on, perhaps one of the device pointers or optix structures are not being allocated properly? The code seems to be crashing on the host side however, as cuda-memcheck does not report any actual kernel crashes, the code might not have even reached the kernel launch stage, merely crashing within the optix host code.

Edit: I went back and reran all the examples, and it appears that some of them do work for me, so here's a list of which examples do and do not work for me.

  1. 01_hello: works
  2. 02_pipeline: segfaults
  3. 03_window: compilation error
  4. 04_mesh: compilation error
  5. 05_sbtdata: compilation error
  6. 06_multiple: compilation error
  7. 07_obj: segfault
  8. 08_texture: works
  9. 09_shadow: segfault
  10. 10_softshadow: segfault
anderslanglands commented 4 years ago

Hello, yes the library is still in a state of some flux right now. I'll try and make sure that the examples are all up-to-date before I push anything to github again. In this case it was because I implemented Drop for DeviceContext and called optixDeviceContextDestroy(), which means that the Renderer struct needs to hold onto the DeviceContext. I've updated the examples to reflect this and all should work correctly now.

oceanusxiv commented 4 years ago

Thanks for the quick response! I totally understand that everything's a WIP, there's just so few projects with Rust and Optix interop active right now, and I very much appreciate the work you're putting into this.