ITADN

DiagBase 'per' parameter is accepted but never triggers output

#1968OpenBenWibking 创建于 2026-06-20
bug: wrong answer/failure/crashI/Ocode-audit
B
BenWibkingcommented
# DiagBase `per` parameter is accepted but never triggers output **Severity:** Medium **File:** `src/io/DiagBase.cpp:10-14` (`init`) and `:53-96` (`doDiag`) ## Explanation `init` reads `per` into `m_per` and the assertion accepts it as a valid trigger: ```cpp pp.query("per", m_per); pp.queryWithParser("time_int", m_time_interval); // time_int takes precedence over per AMREX_ASSERT(m_interval > 0 || m_per > 0.0 || m_time_interval > 0.0); ``` However, `doDiag` only checks `m_interval` (step-based) and `m_time_interval` (time-based); `m_per` is never consulted to decide whether to output. A user who sets only `per = 1.0` (and not `int` or `time_int`) passes the assertion but `doDiag` always returns `false` — the diagnostic never fires. `m_per` is only used for filename formatting in `DiagPDF.cpp:130`. The comment "time_int takes precedence over per" implies `per` was intended to act as a time-based interval (falling back to `time_int` semantics), but the fallback is never implemented. ## Impact Users who configure a diagnostic with only `per` get no output despite the assertion implying it is valid. This is a silent failure. ## Proposed patch In `DiagBase::init`, after reading `m_per`, wire it up as a time interval when `time_int` is not set: ```cpp if (m_time_interval <= 0.0 && m_per > 0.0) { m_time_interval = m_per; } ``` (Alternatively, if `per` is intended only for filename formatting, the assertion should not accept it as a valid output trigger.)
0 条评论