Skip to content

Commit f75154b

Browse files
ggalgocziplexoos
andauthored
fix(qudarap): guard null scint dereference on GPU reemission path (#294)
PR #291 correctly made missing scintillation ICDF non-fatal for valid non-scintillating geometries. This PR addresses a separate case: a problematic material configuration where `REEMISSIONPROB > 0` is present, but no emission spectrum is defined. In the current implementation, the boundary texture still carries a nonzero reemission probability from `qudarap/qbnd.h:195`, even when no `QScint`/ICDF is created because `FASTCOMPONENT` and `SLOWCOMPONENT` are missing. During propagation, a photon can then enter the reemission branch in `qudarap/qsim.h:804` and attempt to sample a reemission wavelength via `scint->wavelength()` in `qudarap/qsim.h:812`, which becomes a null dereference on the GPU. This PR guards that path by treating reemission-without-`QScint` as bulk absorption instead of attempting to reemit. It also guards the scintillation genstep path against a null `scint` pointer. A reproducer geometry is included in `tests/geom/opticks_raindrop_reemit_no_scint.gdml`. In short: - No scintillation properties at all: valid non-scintillating geometry, handled by PR #291 - `REEMISSIONPROB > 0` but no emission spectrum: inconsistent configuration, now guarded to avoid GPU null dereference --------- Co-authored-by: ggalgoczi <ggalgoczi@users.noreply.github.com> Co-authored-by: Dmitri Smirnov <dmixsmi@gmail.com>
1 parent 2f21fff commit f75154b

3 files changed

Lines changed: 204 additions & 1 deletion

File tree

qudarap/qsim.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,12 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
803803

804804
if (u_reemit < reemission_prob)
805805
{
806+
if (scint == nullptr)
807+
{
808+
flag = BULK_ABSORB;
809+
return BREAK;
810+
}
811+
806812
float u_re_wavelength = curand_uniform(&rng);
807813
float u_re_mom_ph = curand_uniform(&rng);
808814
float u_re_mom_ct = curand_uniform(&rng);
@@ -2546,7 +2552,9 @@ inline QSIM_METHOD void qsim::generate_photon(sphoton& p, RNG& rng, const quad6&
25462552

25472553
case OpticksGenstep_DsG4Scintillation_r4695:
25482554
case OpticksGenstep_SCINTILLATION:
2549-
scint->generate( p, rng, gs, photon_id, genstep_id ) ; break ;
2555+
if (scint != nullptr)
2556+
scint->generate(p, rng, gs, photon_id, genstep_id);
2557+
break;
25502558

25512559
case OpticksGenstep_INPUT_PHOTON: { p = evt->photon[photon_id] ; p.set_flag(TORCH) ; } ; break ;
25522560
default: generate_photon_dummy( p, rng, gs, photon_id, genstep_id) ; break ;

0 commit comments

Comments
 (0)