Skip to content

feat: add cpptrace for better stack traces #4042

Draft
kdrienCG wants to merge 54 commits into
feat/rey/lvarray-error-managementfrom
feature/kdrienCG/betterStackTrace
Draft

feat: add cpptrace for better stack traces #4042
kdrienCG wants to merge 54 commits into
feat/rey/lvarray-error-managementfrom
feature/kdrienCG/betterStackTrace

Conversation

@kdrienCG

@kdrienCG kdrienCG commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

(Requires TPL PR #347)

This PR aims to improve the stack trace output when an error is thrown.

When GEOS crashes from a C++ exception, the stack trace we log is not really useful: it points at main.cpp instead of the code that actually threw, missing on valuable informations for devs. This is not a bug in the error handler, it is how the C++ runtime works: by the time we catch, the stack between the throw and the handler has already been unwound, so we cannot recover it ourselves. And we can't instrument every throw site either, since many exceptions come from the standard library itself (like std::map::at for example), which we can't modify.

cpptrace solves this by hooking into the exception "machinery" to capture the stack at throw time, so we get a proper trace even when throw happens inside the std library, which is why we pull it as a dependency rather than rolling our own.

Here is an example defining a myThrowingFunction() incorrectly using a map (written in the main.cpp for convenience)

Without cpptrace:

***** Exception
***** Rank 0
***** Message :
map::at

***** StackTrace of 7 frames
  - Frame  0:  geos::ErrorLogger::initCurrentExceptionMessage(geos::MsgType, std::basic_string_view<char, std::char_traits<char> >, int) 
  - Frame  1:  main /somewhere/in/my/disk/geos/GEOS/src/main/main.cpp:272 (discriminator 3)
  - Frame  2:  __libc_start_main 
  - Frame  3:  _start 
  - Frame  4:  main /somewhere/in/my/disk/geos/GEOS/src/main/main.cpp:275 (discriminator 2)
  - Frame  5:  __libc_start_main 
  - Frame  6:  _start 
*****

With cpptrace:
(truncated to fit the PR description)

***** Exception
***** Rank 0
***** Message :
map::at

***** StackTrace of 15 frames
  - Frame  0: at libstdc++.so.6
  - Frame  1: in __gxx_personality_v0 at libstdc++.so.6
  - Frame  2: at libstdc++.so.6
  - Frame  3: in std::map<std::string, int, std::less<std::string>>::at(std::string const&) at stl_map.h:551:24
  - Frame  4: in myThrowingFunction() at main.cpp:40:24
  - Frame  5: in operator() at main.cpp:49:16
  - Frame  6: in do_try_catch<const geos::NotAnError&, main(int, char**)::<lambda()>&, main(int, char**)::<lambda...
  - Frame  7: in operator() at from_current.hpp:143:32
  - Frame  8: in operator() at from_current.hpp:143:32
  - Frame  9: in operator() at from_current.hpp:143:32
  - Frame 10: in try_catch_impl<main(int, char**)::<lambda()>&, main(int, char**)::<lambda(const geos::NotAnError...
  - Frame 11: in try_catch<main(int, char**)::<lambda()>&, main(int, char**)::<lambda(const geos::NotAnError&)>&...
  - Frame 12: in main at main.cpp:129:22
  - Frame 13: in __libc_start_main at libc.so.6
  - Frame 14: in _start at geosx
*****

We have a detailled stack trace with the name of the function that throws and the correct line and character position.

npillardou and others added 10 commits April 14, 2026 17:34
* Add Poisson's ratio and Young's modulus to register data fields

* Delete comments

* Change logs

* regenerate schema after adding youngModulus/poissonRatio fields to ElasticIsotropic

* Uncrustify

* Rebaseline

---------

Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: dkachuma <dickkachuma@googlemail.com>
* Fix HIP build issues
* LvArray
---------
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
…#4032)

ci: decouple build pipeline from GCP and add per-org/provider config

The reusable workflow and its container script were coupled to Google
Cloud (hardcoded GCP auth step, GCS bucket input, GCP-shaped sccache
credentials). Forks running on different storage backends or self-hosted
runners had to fork the workflow files. This change moves the per-org
and per-provider details into checked-in JSON consumed by a new resolver
job, leaving the workflows declarative.

- Add `.github/ci/orgs/<org>.json` and `.github/ci/providers/<provider>.json`
  as the single source of truth for storage provider, sccache profile,
  artifact bucket path, public URL base, runner labels, and per-runner CA
  bundle paths. Schema is documented and required-field-only (no
  defaults) in `.github/ci/README.md`. Ships configs for EarthFlowAI
  (Cloudflare R2) and GEOS-DEV (GCS).

- Add a `resolve_ci_provider` job in `ci_tests.yml` that loads and
  validates the org+provider JSON and exposes outputs to the matrix
  jobs. Per-row build options stay in `matrix:`; runtime resolution
  lives in the resolver.

- Replace the GCP-only `auth` step in `build_and_test.yml` with a
  provider-agnostic step that resolves sccache config (TOML, env vars,
  files, or a named profile from `SCCACHE_PROFILES_JSON`) and artifact
  upload commands from inherited secrets. Drop `GCP_BUCKET`; add
  `STORAGE_PROVIDER`, `SCCACHE_PROFILE`, `ARTIFACT_UPLOAD_*`, and
  `ARTIFACT_PUBLIC_URL_*` inputs.

- Support self-hosted runners with private trust stores via
  `DOCKER_CA_BUNDLE_HOST_PATH`, mounted into the container as
  `/certs/ca-bundle.crt`.

- Generalize the in-container script: drop the GCP-coupled
  `--sccache-credentials` flag in favor of `--use-sccache` plus a
  relative `--sccache-config` path. Add phase timing instrumentation
  (per-phase start/duration markers and an end-of-run summary). Remove a
  stray `printenv` that was leaking secrets into job logs.

- Fix label re-checking on private repos: restore live REST API fetch in
  `does_pr_have_necessary_labels` (the frozen
  `github.event.pull_request` payload misses labels added after the
  first trigger), and add the `Authorization: Bearer ${GITHUB_TOKEN}`
  header so private repos and fork PRs don't get an empty response.
  Switch the draft-PR check to read `github.event.pull_request.draft`
  directly instead of the REST API round-trip.
@kdrienCG kdrienCG self-assigned this Apr 28, 2026
@kdrienCG kdrienCG added type: feature New feature or request flag: requires updated TPL(s) Needs a specific TPL PR labels Apr 28, 2026
tjb-ltk and others added 11 commits April 30, 2026 10:26
* thermal prod well inflow der fix
* activate more unit tests, fix for case where there is 2 phase injection, probably an artifact of this unit test
* cleanup inflow ders
* use correct density for upstream inflow calc
* clarify and fix test
* refactor for PR review 1) prodwell mobs are not recomputed, 2) thermal inj well calcs need a bit of streamlining, but first lets see if the reg tests still work
* add stackvariables and arrayslices
* rearrange compute order to match integratedTests
* streamline loops
* Update src/coreComponents/physicsSolvers/fluidFlow/wells/kernels/PerforationFluxKernels.hpp

Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>

* fix schema

* review suggestion

---------

Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
…4045)

* reanable sccache using a legacy backup that uses existing GCP secret

* fix sccache stats output step
…updates (#4044)

Bumps the github-actions group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [codecov/codecov-action](https://github.com/codecov/codecov-action).


Updates `actions/checkout` from 4.2.2 to 6.0.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4.2.2...v6.0.2)

Updates `codecov/codecov-action` from 5.4.2 to 6.0.0
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v5.4.2...v6.0.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: codecov/codecov-action
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions

Co-authored-by: Randolph Settgast <randolph.settgast@earthflow.ai>
@kdrienCG kdrienCG marked this pull request as ready for review May 5, 2026 16:50
castelletto1 and others added 2 commits May 8, 2026 22:37
* Fixing macOS build

* update PVTPackage submodule hash
* Draft
* tol

---------

Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Randolph Settgast <randolph.settgast@earthflow.ai>
#define GEOS_COMMON_LOGGER_STACKTRACE_HPP

#include "common/GeosxConfig.hpp" // For the following guards
#ifdef GEOS_USE_CPPTRACE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all the calls involving cpptrace are static I would move anything related to choosing whether cpptrace is used to the .cpp file to leave the header unencumbered by these macros.

OmarDuran and others added 7 commits May 13, 2026 14:35
* wip: decrease mesh sizes.
* wip: process testFEMConsistency
* wip: process testSurfaceGenerator
* wip:
* wip: process testMixedDimSinglePhaseFlow
* wip: uncrustify
* wip: remove DFN_5_fractures_hex_binarized and DFN_5_fractures_tet_binarized from mpi tests
* wip: no need to test the same topology in testSurfaceGenerator
* wip: no need to test the wavy meshes in testMixedDimHydrostaticEquilibrium_mpi
* wip: test wavy and flat meshes in separate tests
* wip: mpi test full span on tets and no boundary for hex
* wip: mpi test full span meshes targeting BC data on ghosted surface cells
* Trigger CI
* Fix event check
* Update src/coreComponents/events/EventBase.cpp
* Use std::clamp

---------

Co-authored-by: Jacques Franc <49998870+jafranc@users.noreply.github.com>
* draft/ enable disp update in SEQ ALM

* throw error if not one of the model

* update slip calculation for ALM

* reset bubble displacement after initialization

* add ExponentialDecayPermeability model

* add a check for totalBubbleDisplacement

* missing include

* more reset

* refactor: Change nodeset import from Int64 to unsigned integer (#4018)

* Refactored importNodesets
* Update dfn_market meshes
* Uncrustify
* Replace bitwise AND with equality check

* some comments clean up + robustness

* add a missing placeholder

* uncrustify

* fix compilation error

* add conditional check to contact solver fields

* allow constant permeability model

* Update src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp

Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>

* revert a change

* Update baseline for integrated tests

* Update BASELINE_NOTES.md

* address review comment

---------

Co-authored-by: Jian HUANG <jian.huang@totalenergies.com>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
* try local newell

* Local Newell / debug

* clean up

* some more warning

* discard unused and style

* std::sqrt->LvArray

* fix constness in test

* style

* epsiloning Surface Gen to avoid zero div w/ new normals

* rebaseline

* fix repeated entry in test

* ERRROR>WARNING and cleanup

* Update baseline entry for PR #3977

Updated the link for PR #3977 to the new baseline tar.gz file.

* Update baseline path in integrated tests configuration

---------

Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
* Draft

* Fixed label

* Path

* Path

* Typo

* Path again

* Rabaseline

---------

Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
* fix: Fix SeismicityRate script.

* add write tables option.

* fix syntax.

---------

Co-authored-by: Pavel Tomin <paveltomin@users.noreply.github.com>
Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
@MelReyCG

Copy link
Copy Markdown
Contributor

Hi @rrsettgast,
As an example, how do you simply throw from a std::map exception?

@rrsettgast

Copy link
Copy Markdown
Contributor

Hi @rrsettgast, As an example, how do you simply throw from a std::map exception?

I assume you mean in the case of the std wrappers, so I will restrict my response to this case. You don't need to throw a std::map exception. The wrapper gives flexibility so you can mimic what was done for bounds checks in LvArray which would result in a well located stack trace and an abort().

jhuang2601 and others added 17 commits May 18, 2026 08:21
* add checks for mechanical properties

* Update src/coreComponents/constitutive/solid/porosity/BiotPorosity.hpp

* Apply suggestion from @castelletto1

* fix CI failures

---------

Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
* add static class for FieldSpecification behavior

* change calls from FSBase to FSImpl in FSManager

* CMBase: update calls to FieldSpecificationImpl

* CMHybridFVM: update calls to FieldSpecificationImpl

* RCMOBL: update calls to FieldSpecificationImpl

* SPBase: update calls to FieldSpecificationImpl

* SPFVM: update calls to FieldSpecificationImpl

* SPHybridFVM: update calls to FieldSpecificationImpl

* SPReactiveTransport: update calls to FieldSpecificationImpl

* ImmiscibleMP: update calls to FieldSpecificationImpl

* SeismicityRate: update calls to FieldSpecificationImpl

* LaplaceBaseH1: update calls to FieldSpecificationImpl

* fix: add missing `fs` parameter to an applyBoundaryConditionToSystem call

* PhaseFieldDamageFEM: update calls to FieldSpecificationImpl

* SMLagrangianFEM: update calls to FieldSpecificationImpl

* SMEmbFractures: update calls to FieldSpecificationImpl

* SMLCBS: update calls to FieldSpecificationImpl

* ProppantTransport: update calls to FieldSpecificationImpl

* testRecFieldAppl: update calls to FieldSpecificationImpl

* add FieldSpecification as temporary alias of FieldSpecificationBase

* AquiferBC: update calls to FieldSpecification

* DirichletBC: update calls to FieldSpecification

* EquilibriumIC: update calls to FieldSpecification

* FSImpl: update calls to FieldSpecification

* PerfectlyMatchedLayer: update calls to FieldSpecification

* SourceFluxBC: update calls to FieldSpecification

* TractionBC: update calls to FieldSpecification

* FSManager: update calls to FieldSpecification

* FluxApproxBase: update calls to FieldSpecification

* ProblemManager: update calls to FieldSpecification

* testRecFieldAppl: update calls to FieldSpecification

* testXMLFile: update calls to FieldSpecification

* CMBase: update calls to FieldSpecification

* CMFVM: update calls to FieldSpecification

* CMHybridFVM: update calls to FieldSpecification

* ImmiscibleMF: update calls to FieldSpecification

* RCMOBL: update calls to FieldSpecification

* SPBase: update calls to FieldSpecification

* SPFVM: update calls to FieldSpecification

* SPHybridFVM: update calls to FieldSpecification

* SPRT: update calls to FieldSpecification

* ProppantTransport: update calls to FieldSpecification

* SeismicityRate: update calls to FieldSpecification

* LaplaceBaseH1: update calls to FieldSpecification

* PhaseFieldDamageFEM: update calls to FieldSpecification

* SMLFEM: update calls to FieldSpecification

* SMEmbFrac: update calls to FieldSpecification

* SMLCBS: update calls to FieldSpecification

* AWEDG: update calls to FieldSpecification

* AFOWESEM: update calls to FieldSpecification

* AVTIWESEM: update calls to FieldSpecification

* AWESEM: update calls to FieldSpecification

* EFOWESEM: update calls to FieldSpecification

* EWESEM: update calls to FieldSpecification

* replace FieldSpecificationBase with FieldSpecification

ProppantTransport.hpp and PhaseFieldDamageFEM.hpp both had the "class FieldSpecification;" line that would cause an error with the temporary alias in FieldSpecification.hpp. That's why they are in this commit.

* fix extension name in CMakeLists.txt

* add brief documentation

* uncrustify

* resolve conflict

* FieldApplicator: update calls to FS and FSImpl

* fix doxygen parameter name

* move long method definitions below the class

* one line one liners

* move FSManager apply checks into an FSImpl

* remove includes

* one line getCatalogName method in FieldSpecification

* relocate solver's applyFieldValue

The affected part may need a larger refactor to generalize logging on field application.

* Format lines to stay under 100 char

(when appropriate)

* remove unnecessary include

* uncrustify

* fix type

* remove commented code

* remove unused or transitive includes

---------

Co-authored-by: Omar Duran <oduran@stanford.edu>
Co-authored-by: Randolph Settgast <randolph.settgast@earthflow.ai>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
* Trim tests

* Update baseline notes with recent PR entries

Added entries for pull requests 4055, 4029, and 3959 with details.

* Update baseline for integrated tests

* rebaseline

---------

Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
)

* Draft

* working version

* Clean

* Clean

* Fixed map

* Clean

* gpu

* Clean Omar

* JF Review

* Missing protection

* stdContainer 1

* stdContainer 2

* stdContainer 3

* Added schema

* rebaseline

---------

Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Omar Duran <oduran@stanford.edu>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
* Switched to size_t, adressed reviews.

* Fixed sequential mode

* Limit parallel test to 4 ranks

* zoltan int

* Missing size_t

* Included extended neighbors for coloring

* Uncrustify

* container

* random graph test

* rebaseline

---------

Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Omar Duran <oduran@stanford.edu>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
* Fix surface generator diffusion

* Access only defined values

* Add line

* Remove line

---------

Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
* Remove dependence of PVT package

* Remove documentation about pvt package

* Exclude PVTPackage from code checks

* Skip PVTPackage from documentation generation

* Rebaseline

* Reintroduce doc index file

* Update baselines
This PR corrects the use of hard-coded Porous Solid model for ALM solver from :

PorousSolid< ElasticIsotropic, ConstantPermeability > to a type dispatch list.

This allows to setup other kind of mechanical model for matrix surrounding faults such as Drucker-Prager.

Also, switch to iterative solver to fix timeout issue in inputFiles/singlePhaseFlow/FieldCaseTutorial3_Thermal_smoke.xml
* add-code-rules

* comment jobs not needed

* try this

* remove ctest testcoderule

* try to add some target

* relaunch ci

* forget 1 target

* test code for detecting std::map

* force to true

* log

* more log

* print pwd

* test with regex

* fix

* update find

* update prefix file pattern

* move to script

* fix rule ^^

* test perm

* add write

* give perm

* give perm

* attempt perm

* remove if statement

* test ls

* test another pwd

* fix cd

* add src

* go to src

* remove prefix

* sabotage code

* missing :

* display info at the end

* check str

* wrong varaible

* echo

* simplify

* remove done

* remove bracket

* add more std

* update logic

* fix std

* style

* remove lr

* set stdUnorderedMap

* vector rule

* add common

* replace std::vector

* revert on stdContainerWrapper

* echo file

* another echo

* add id cond

* stdVector

* missing file

* test for constituve

* try refacto with func

* clean the code + test with file

* fix declaration

* log

* update echo

* refacto find cmd

* remove exclude find

* remove log + revert

* update find command

* remove type f

* remove var from find

* reset find

* revert loop

* update loop

* update code

* enforce code

* echo file

* fix loop

* revert some ci change + remove echo

* print all path + some refacto

* remove debug log

* uncrustify

* factorize duplicated code

* simplify functions

* centralize declaration of forbedden expression

* syntax correction

* add code  rules  in check_all_tests_succedeed

* renaming

* ♻️ name clarity refactor

* opti code rules

* fix confition in test & update container

* correction script

* address last comments

* fix if command

* disable graph coloring test

* add get inserted method

* uncrustidy + rmove comment + add TODO

* 🎨 TODO uppercase

* 🎨 use of stdContainerWrapper

* fix

* fix

* fix: revert uncrustify formatting on SpatialPartition.cpp

* ⚡️ fixing std::move usage, removing needs for useless copies

* 🐛 fix some get_inserted() usage

* 🎨 uncrustify

---------

Co-authored-by: MelReyCG <melvin.rey@capgemini.com>
Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com>
Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com>
Co-authored-by: Bertrand Denel <120652669+bd713@users.noreply.github.com>
Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
- remove dependency to cpptrace in StackTrace header
- move stacktrace dispatch logic from main to StackTraceParams
- move stacktrace decoding from ErrorHandling to StackTrace
…dels (#4058)

This PR refactors the compositional multiphase fluid framework, replacing hardcoded 2/3-phase templates with variadic templates (typename... PHASES) to support an arbitrary number of fluid phases. This provides the foundational architecture needed for thermal compositional models.
…) (#4072)

* Fix multifluid mole-fraction derivative initialization for GCC15 (#4070)

* Fix molality calculation in MultiFluidBase.hpp

* Fix calculation of component mole fraction

* Change

* Change

---------

Co-authored-by: LiYang <liyangcup@gmail.com>
* enable smoke tests with MPI runs

* update rebaseline tag

* test ordering

* test ordering

* map

* rebaseline test

* Update src/coreComponents/physicsSolvers/surfaceGeneration/SurfaceGenerator.hpp

Co-authored-by: Jacques Franc <49998870+jafranc@users.noreply.github.com>

---------

Co-authored-by: DENEL Bertrand <bertrand.denel@total.com>
Co-authored-by: Jacques Franc <49998870+jafranc@users.noreply.github.com>
Co-authored-by: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com>
@kdrienCG kdrienCG changed the base branch from develop to feat/rey/lvarray-error-management June 12, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: requires updated TPL(s) Needs a specific TPL PR type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.