Skip to content

Segmentation fault in Mgxs::get_xs when using DAGMCUniverse and multi-group energy mode #3929

@hugo-barthod

Description

@hugo-barthod

files.zip

Bug Description

When running OpenMC with <energy_mode>multi-group</energy_mode>, a segmentation fault (SIGSEGV) occurs in Mgxs::get_xs if openmc attempts to advance (Particle::event_advance) a particle whose material_ is set to MATERIAL_VOID (-1).
The crash occurs because Particle::speed attempts to query data from an ill-formed Mgxs object.

In my particular case, I used a DAGMCUniverse.
It seems material_ = -1 is affected to the Particle p because it is located in the implicit complement cell.

Backtrace

*** Process received signal ***
Signal: Segmentation fault (11)
Signal code: (128)
Failing at address: (nil)
[ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x753f8ea42520]
[ 1] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(_ZN6openmc4Mgxs6get_xsENS_8MgxsTypeEiPKiPKdS3_ii+0x25b)[0x753f8f74f55b]
[ 2] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(_ZNK6openmc8Particle5speedEv+0xd3)[0x753f8f775533]
[ 3] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(_ZN6openmc8Particle13event_advanceEv+0x72)[0x753f8f775be2]
[ 4] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(_ZN6openmc39transport_history_based_single_particleERNS_8ParticleE+0x61)[0x753f8f7ec041]
[ 5] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(+0x1ec133)[0x753f8f7ec133]
[ 6] /home/miniconda3/envs/openmc-env/bin/../lib/libgomp.so.1(GOMP_parallel+0x46)[0x753f8f5c3a66]
[ 7] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(openmc_next_batch+0x8d)[0x753f8f7edc7d]
[ 8] /home/miniconda3/envs/openmc-env/bin/../lib/libopenmc.so(openmc_run+0x89)[0x753f8f7edd99]
[ 9] openmc(+0x2104)[0x65391388d104]
[10] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x753f8ea29d90]
[11] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x753f8ea29e40]
[12] openmc(+0x2151)[0x65391388d151]
*** End of error message ***
Erreur de segmentation (core dumped)

Steps to Reproduce

The dagmc.h5m, model.xml and MGXSLibrary.h5 files attached in files.zip can be used to reproduce the bug.
In a directory with these 3 files, run openmc -s 1.

Environment

  • OS: Linux (x86_64)
  • OpenMC version: 0.15.3
  • Install method: conda (openmc-env, recommended)
  • Nuclear data: Multigroup custom openmc.MGXSLibrary

Partial fix

PR #3766 addresses the immediate crash by preventing Particle::speed from accessing the ill-formed Mgxs object when material_ is MATERIAL_VOID.

Possible further fix

Currently, if the location of a Particle p cannot be found by DAGUniverse::find_cell, the Particle is silently located in the implicit complement cell.
It may be confusing for the user if they do not expect their dagmc.h5m file to have gaps.
It could be nice to have a --implicit-complement-debug running mode (similar to the --geometry-debug mode) where a WARNING would be logged everytime DAGUniverse::find_cell affects a particle to the implicit complement, similar to what is done by Particle::mark_as_lost

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions