Portability and latent-crash fixes: FE_Element guard, PythonStream format string, DistributedSuperLU name collision#30
Open
nmorabowen wants to merge 3 commits into
Conversation
The FE_Element(tag, numDOF_Group, ndof) constructor used by subtype adapters incremented the class-wide numFEs counter BEFORE the `if (numFEs == 0)` guard that lazily allocates the shared theMatrices/theVectors scratch arrays. The guard was therefore never taken, so a model whose only FE_Elements are subtype adapters (no element-backed FE_Element is ever constructed) left those arrays unallocated and dereferenced a null pointer in ~FE_Element when the last FE_Element was destroyed. Move the increment below the guard, matching the element-backed constructor. Any model that already owns an element-backed FE_Element is unaffected: numFEs is already > 0 by the time subtype adapters are built. Co-authored-by: Patricio Palacios <pxpalacios@miuandes.cl> Co-authored-by: Jose A. Abell <jaabell@miuandes.cl>
err_out passed the already-formatted message directly as the format argument of PySys_FormatStderr. Any literal '%' in an opserr message (e.g. "50% of model mass") was interpreted as a printf conversion specifier, so the message was silently dropped or garbled under openseespy. The Tcl StandardStream path was unaffected. Pass the message through a "%s" format instead. Co-authored-by: Patricio Palacios <pxpalacios@miuandes.cl> Co-authored-by: Jose A. Abell <jaabell@miuandes.cl>
The file-scope global SuperLUStat_t stat collides with the POSIX stat() function declared transitively through <sys/stat.h>/<io.h> on some toolchains (notably MSVC), breaking the Windows build of the distributed SuperLU solver. Rename it to superlu_stat at all four use sites; no behavior change. Co-authored-by: Patricio Palacios <pxpalacios@miuandes.cl> Co-authored-by: Jose A. Abell <jaabell@miuandes.cl>
nmorabowen
added a commit
to nmorabowen/OpenSees
that referenced
this pull request
Jul 23, 2026
…es.cl fix (#606) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small, independent, non-behavioral fixes (one commit each, so any can be dropped). None changes results for a correctly-running model.
1. Dead first-element guard in
FE_Elementsubtype constructorFE_Element(tag, numDOF_Group, ndof)incremented the class-widenumFEscounter before theif (numFEs == 0)guard that lazily allocates the sharedtheMatrices/theVectorsscratch arrays, so the guard was never taken. A model whose onlyFE_Elements are subtype adapters (no element-backedFE_Elementever constructed) then left those arrays unallocated → null dereference in~FE_Elementwhen the last one is destroyed. Fix: increment after the guard, matching the element-backed constructor. Any model that owns at least one element-backedFE_Elementis unaffected (numFEs > 0by the time subtypes are built).2. Format-string bug in
PythonStream::err_outThe already-formatted message was passed as the format argument of
PySys_FormatStderr, so any literal%in anopserrmessage (e.g."50% of model mass") was consumed as a bogus printf conversion and the message dropped/garbled under openseespy. The Tcl stream path was unaffected. Fix:PySys_FormatStderr("%s", msg.c_str()).3.
DistributedSuperLUglobalstatcollides with POSIXstat()The file-scope
SuperLUStat_t statcollides with the POSIXstat()declared transitively via<sys/stat.h>/<io.h>on some toolchains (notably MSVC), breaking the Windows build of the distributed SuperLU solver. Renamed tosuperlu_statat all four use sites; no behavior change.Authors: Nicolas Mora Bowen, Patricio Palacios, José A. Abell