Skip to content

feat: Adding signal and external error detection & output #3722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 89 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c846586
creation of an object header that logs errors and warnings in a yaml …
amandinehry Apr 25, 2025
f1713fa
Set up ErrorHandling
amandinehry Apr 30, 2025
4e5250f
traits errors commented (to treat)
amandinehry Apr 30, 2025
94b775c
Set up test
amandinehry Apr 30, 2025
1cb8aa3
Modification to properly format the yaml so that it can be parsed if …
amandinehry Apr 30, 2025
9d5e16a
Test to add variadic arguments
amandinehry May 2, 2025
2f7660c
draft: retrieve data contexts info
amandinehry May 5, 2025
6036551
Added additional information in the yaml - not functional missing the…
amandinehry May 5, 2025
46b4904
First attempt at outputting exceptions
amandinehry May 7, 2025
e1aed93
Complete: code for outputting errors into yaml
amandinehry May 9, 2025
bc953be
Manage the text contained in the potential exception
amandinehry May 12, 2025
1a434bc
First attempt: Handling the text contained in the potential exception…
amandinehry May 14, 2025
acf4d99
Complete: yaml output for PVT tables error
amandinehry May 16, 2025
ee58884
YAML error message well formatted
amandinehry May 19, 2025
32a0237
Fix duplication error
amandinehry May 19, 2025
589270f
Add variadic parameters to GEOS_THROW_CTX_IF
amandinehry May 21, 2025
9b65581
Reorganization after operational tests
amandinehry May 21, 2025
b13f0a6
Apply the output error functionality in yaml to all geos errors
amandinehry May 21, 2025
6de2c6a
Latest update for exception handling (try/catch in main)
amandinehry May 27, 2025
5830aee
Add priority to the error message into the yaml file
amandinehry May 27, 2025
2b27c41
Update of the commit named "latest update for exception handling (try…
amandinehry May 27, 2025
86f793e
set priority
amandinehry May 27, 2025
8a8117e
errors cli modification: add --errors-output
amandinehry May 27, 2025
2c0f5aa
errors cli modification: add --errors-output
amandinehry May 27, 2025
eb2f691
Replace original macros
amandinehry May 27, 2025
7b5f293
Correction: replace original macros
amandinehry May 27, 2025
c07b502
Modification of the Optional function to accept arguments separated b…
amandinehry Jun 2, 2025
670ddfa
Reacting with the command line option -e / --errors-output
amandinehry Jun 2, 2025
d08a30f
Add the rank on which the error is catch for error and warning outputs
amandinehry Jun 3, 2025
5a6c1a0
Unit test to check if the contents of the yaml file match exactly wha…
amandinehry Jun 3, 2025
4928dcd
Add the "Exception" field into the message type enumeration
amandinehry Jun 4, 2025
02dcf50
Modify the macros corresponding to throw to allow the exception to be…
amandinehry Jun 4, 2025
59ac94d
Remove ASSERT dependency on LvArray
amandinehry Jun 4, 2025
835e444
Remove GEOS_THROW_(...) and GEOS_ERROR_(...) dependency on LvArray
amandinehry Jun 4, 2025
10a2627
Restore to its original state an input file that I used for my tests
amandinehry Jun 4, 2025
9bd9f30
Delete additionnal spaces
amandinehry Jun 4, 2025
c9fea30
Syntax fixes
amandinehry Jun 4, 2025
7fa2b74
Syntax fixes
amandinehry Jun 4, 2025
8a9ff29
xsd + revert comment
amandinehry Jun 4, 2025
c1e001e
xsd + check includes
amandinehry Jun 4, 2025
e31f17c
Merge remote-tracking branch 'upstream/develop' into feature/amandine…
amandinehry Jun 4, 2025
a0eefd2
Compilation error fix
amandinehry Jun 5, 2025
5caa099
Remove vscode config files
amandinehry Jun 5, 2025
7aee0c6
Remove empty comment lines and commented code
amandinehry Jun 10, 2025
80bb07b
Changes in macros names
amandinehry Jun 10, 2025
149789e
Change the loop syntax ito a for-each syntax to solve the issue of in…
amandinehry Jun 10, 2025
74de273
Add comments
amandinehry Jun 10, 2025
92e6854
Reorganization of declarations
amandinehry Jun 10, 2025
f910d0e
add g_ before global variables + add comment to the addToMsg() method
amandinehry Jun 10, 2025
67fce43
Fix in writing the stack trace in the yaml
amandinehry Jun 11, 2025
387687d
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
amandinehry Jun 11, 2025
5c801a5
Add an error msg when the call stack is not formatted as expected + r…
amandinehry Jun 11, 2025
e34c90d
Add comment in the write() function
amandinehry Jun 11, 2025
5c4fbcb
Modification of the streamMultilineYamlAttribute() function: no longe…
amandinehry Jun 11, 2025
75eff27
Modification of the streamMultilineYamlAttribute() method: take the i…
amandinehry Jun 11, 2025
dab2da5
Fix null pointer access on parent by using instance field instead
amandinehry Jun 11, 2025
0a95296
Add comments
amandinehry Jun 11, 2025
c4a002e
Just silently kill GEOS when a NotAnError is raised
amandinehry Jun 11, 2025
cbc5102
Removed the pointer to an Error Logger object (this is no longer usef…
amandinehry Jun 12, 2025
3318d85
Minor syntax modification
amandinehry Jun 12, 2025
343b830
Renaming ContextInfo in ErrorContext + minor correction on the format…
amandinehry Jun 12, 2025
e22e538
Minor modifications on the GEOS_THROW_IF_GT_MSG message
amandinehry Jun 12, 2025
8de9060
Using GEOS_LOG_RANK instead of GEOS_LOG
amandinehry Jun 12, 2025
6c762e7
Add an enumeration to secure the keys that can be entered for the map…
amandinehry Jun 12, 2025
d288490
Improved code comments
amandinehry Jun 13, 2025
99d9b5b
reverse the change from GEOS_LOG to GEOS_LOG_RANK +empty the object a…
amandinehry Jun 13, 2025
f929f97
minor changes syntax + remove isValidStackTrace() method and replace …
amandinehry Jun 13, 2025
709d8a4
Minor changes: string to string_view when it was possible + add an ad…
amandinehry Jun 16, 2025
051e85b
Remove try/catch in the createFile() and the flushCurrentErrorMsg() m…
amandinehry Jun 16, 2025
517782b
Renaming: flushCurrentErrorMsg() into flushErrorMsg()
amandinehry Jun 16, 2025
2e0e396
Change GEOS_LOG() to GEOS_LOG_RANK()
amandinehry Jun 18, 2025
a83a3a1
initialize the error message line by default
amandinehry Jun 19, 2025
9fe289a
Doxygen comments
amandinehry Jun 24, 2025
da7dc82
Comments added
amandinehry Jun 24, 2025
260133e
Sort contextual information by decreasing priority
amandinehry Jun 24, 2025
e0c876f
Simplification of the for loop which write context information
amandinehry Jun 24, 2025
e1a2128
Changes following comments received on my PR
amandinehry Jun 25, 2025
4811b6c
Unit test implemented
amandinehry Jun 25, 2025
cee846a
✨ manage exit signals in GEOS, as errors + signal log messages no lon…
MelReyCG Jul 7, 2025
6c24825
💄 ajusting line break for consistency
MelReyCG Jul 7, 2025
9e46565
💄 add an option to reorder error msg parts, useful for signal msgs.
MelReyCG Jul 7, 2025
098c478
✨ capture external errors from stderr pipe in GEOS
MelReyCG Jul 7, 2025
7b1b383
✨ ♻️ adding detection location context information for signals & exte…
MelReyCG Jul 7, 2025
25c2418
💄 removing empty entries output from YAML
MelReyCG Jul 7, 2025
2ed4144
💄 adding detectionLocation YAML key
MelReyCG Jul 7, 2025
bdc07b2
💄 adding signal error metadata
MelReyCG Jul 7, 2025
2b38577
Merge commit '7e85e747ec65cd498ba0e9e4730f79d2692ed0bd' into feature/…
MelReyCG Jul 8, 2025
531e3e3
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' int…
MelReyCG Jul 8, 2025
8077f10
sync with last feature/amandinehry/create-yaml-file-and-structure cha…
MelReyCG Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/coreComponents/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Also provides commonly used components for such as logging, formatting, memory a
dependencies.
#]]


#
# Specify all headers
#
Expand All @@ -32,7 +31,6 @@ set( common_headers
format/LogPart.hpp
format/Format.hpp
format/StringUtilities.hpp
logger/Logger.hpp
BufferAllocator.hpp
DataLayouts.hpp
DataTypes.hpp
Expand All @@ -41,6 +39,8 @@ set( common_headers
GeosxMacros.hpp
MemoryInfos.hpp
logger/Logger.hpp
logger/ErrorHandling.hpp
logger/ExternalErrorHandler.hpp
MpiWrapper.hpp
Path.hpp
Span.hpp
Expand Down Expand Up @@ -76,6 +76,8 @@ set( common_sources
format/LogPart.cpp
format/StringUtilities.cpp
logger/Logger.cpp
logger/ErrorHandling.cpp
logger/ExternalErrorHandler.cpp
BufferAllocator.cpp
MemoryInfos.cpp
MpiWrapper.cpp
Expand Down
89 changes: 74 additions & 15 deletions src/coreComponents/common/initializeEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "common/format/table/TableFormatter.hpp"
#include "common/LifoStorageCommon.hpp"
#include "common/MemoryInfos.hpp"
#include "logger/ExternalErrorHandler.hpp"
#include <umpire/TypedAllocator.hpp>
// TPL includes
#include <umpire/ResourceManager.hpp>
Expand Down Expand Up @@ -67,6 +68,79 @@ void setupLogger()
#else
logger::InitializeLogger();
#endif

{ // setup error handling (using LvArray helper system functions)
using ErrorContext = ErrorLogger::ErrorContext;

///// set Post-Handled Error behaviour /////
LvArray::system::setErrorHandler( []()
{
#if defined( GEOS_USE_MPI )
int mpi = 0;
MPI_Initialized( &mpi );
if( mpi )
{
MPI_Abort( MPI_COMM_WORLD, EXIT_FAILURE );
}
#endif
std::abort();
} );

///// set external error handling behaviour /////
ExternalErrorHandler::instance().setErrorHandling( []( string_view errorMsg,
string_view detectionLocation )
{
std::string const stackHistory = LvArray::system::stackTrace( true );
ErrorLogger::ErrorMsg error;
error.setType( ErrorLogger::MsgType::Error );
error.addToMsg( errorMsg );
error.setRank( ::geos::logger::internal::rank );
error.addCallStackInfo( stackHistory );
error.addContextInfo(
ErrorContext{ { { ErrorContext::Attribute::DetectionLoc, string( detectionLocation ) } } } );

GEOS_LOG( GEOS_FMT( "***** ERROR\n"
"***** LOCATION: (external error, detected {})\n"
"{}\n{}",
detectionLocation, error.m_msg, stackHistory ) );
g_errorLogger.flushErrorMsg( error );

// we do not terminate the program as 1. the error could be non-fatal, 2. there may be more messages to output.
} );
ExternalErrorHandler::instance().enableStderrPipe( true );

///// set signal handling behaviour /////
LvArray::system::setSignalHandling( []( int const signal )
{
// Disable signal handling to prevent catching exit signal (infinite loop)
LvArray::system::setSignalHandling( nullptr );

// first of all, external error can await to be output, we must output them
ExternalErrorHandler::instance().flush( "before signal error output" );

// error message output
std::string const stackHistory = LvArray::system::stackTrace( true );
ErrorLogger::ErrorMsg error;
error.setType( ErrorLogger::MsgType::Error );
error.addSignalToMsg( signal );
error.setRank( ::geos::logger::internal::rank );
error.addCallStackInfo( stackHistory );
error.addContextInfo(
ErrorContext{ { { ErrorContext::Attribute::Signal, std::to_string( signal ) } }, 1 },
ErrorContext{ { { ErrorContext::Attribute::DetectionLoc, string( "signal handler" ) } }, 0 } );

GEOS_LOG( GEOS_FMT( "***** ERROR\n"
"***** SIGNAL: {}\n"
"***** LOCATION: (external error, captured by signal handler)\n"
"{}\n{}",
signal, error.m_msg, stackHistory ) );
g_errorLogger.flushErrorMsg( error );

// call program termination
LvArray::system::callErrorHandler();
} );

}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -78,21 +152,6 @@ void finalizeLogger()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setupLvArray()
{
LvArray::system::setErrorHandler( []()
{
#if defined( GEOS_USE_MPI )
int mpi = 0;
MPI_Initialized( &mpi );
if( mpi )
{
MPI_Abort( MPI_COMM_WORLD, EXIT_FAILURE );
}
#endif
std::abort();
} );

LvArray::system::setSignalHandling( []( int const signal ) { LvArray::system::stackTraceHandler( signal, true ); } );

#if defined(GEOS_USE_FPE)
LvArray::system::setFPE();
#else
Expand Down
Loading
Loading