@@ -781,16 +781,6 @@ namespace vix::commands::RunCommand::detail
781781#endif
782782
783783#ifndef _WIN32
784- bool log_looks_like_sanitizer_or_ub (const std::string &log)
785- {
786- return log.find (" runtime error:" ) != std::string::npos ||
787- log.find (" UndefinedBehaviorSanitizer" ) != std::string::npos ||
788- log.find (" AddressSanitizer" ) != std::string::npos ||
789- log.find (" LeakSanitizer" ) != std::string::npos ||
790- log.find (" ThreadSanitizer" ) != std::string::npos ||
791- log.find (" MemorySanitizer" ) != std::string::npos;
792- }
793-
794784 bool handle_error_tip_block_vix (const std::string &log)
795785 {
796786 const auto epos = log.find (" error:" );
@@ -852,27 +842,6 @@ namespace vix::commands::RunCommand::detail
852842 }
853843#endif
854844
855- #ifndef _WIN32
856- bool log_looks_like_runtime_crash (const LiveRunResult &rr, const std::string &log)
857- {
858- if (rr.terminatedBySignal )
859- return true ;
860-
861- if (log_looks_like_sanitizer_or_ub (log))
862- return true ;
863-
864- return log.find (" Segmentation fault" ) != std::string::npos ||
865- log.find (" segmentation fault" ) != std::string::npos ||
866- log.find (" core dumped" ) != std::string::npos ||
867- log.find (" Aborted" ) != std::string::npos ||
868- log.find (" terminate called" ) != std::string::npos ||
869- log.find (" std::terminate" ) != std::string::npos ||
870- log.find (" double free" ) != std::string::npos ||
871- log.find (" invalid pointer" ) != std::string::npos ||
872- log.find (" stack smashing detected" ) != std::string::npos;
873- }
874- #endif
875-
876845 bool has_ccache ()
877846 {
878847#ifdef _WIN32
@@ -1553,41 +1522,51 @@ namespace vix::commands::RunCommand::detail
15531522 {
15541523 return 0 ;
15551524 }
1556- const bool looksSanOrUb =
1557- !runtimeLog.empty () && log_looks_like_sanitizer_or_ub (runtimeLog);
1525+ const vix::cli::errors::RuntimeCrashEvidence evidence{
1526+ rr.terminatedBySignal ,
1527+ rr.termSignal };
1528+ const bool hasRuntimeEvidence =
1529+ vix::cli::errors::RawLogDetectors::hasAuthoritativeRuntimeEvidence (
1530+ runtimeLog,
1531+ evidence);
15581532
15591533 const bool noOutput =
15601534 trim_copy (rr.stdoutText ).empty () &&
15611535 trim_copy (rr.stderrText ).empty ();
15621536
1563- if (runCode == 0 && !looksSanOrUb && noOutput)
1537+ if (runCode == 0 && !hasRuntimeEvidence && noOutput)
15641538 {
15651539 if (!opt.quiet || ::isatty (STDOUT_FILENO ) != 0 )
15661540 vix::cli::style::hint (" Program exited successfully (code 0) but produced no output." );
15671541
15681542 return 0 ;
15691543 }
15701544
1571- if (runCode != 0 || looksSanOrUb )
1545+ if (runCode != 0 || hasRuntimeEvidence )
15721546 {
1573- if (runCode == 0 && looksSanOrUb )
1547+ if (runCode == 0 && hasRuntimeEvidence )
15741548 runCode = 1 ;
15751549
15761550 bool handled = false ;
15771551
15781552 if (!runtimeLog.empty ())
15791553 {
1580- handled = handle_error_tip_block_vix (runtimeLog);
1554+ if (hasRuntimeEvidence)
1555+ handled = handle_error_tip_block_vix (runtimeLog);
15811556
15821557 const bool maybeRuntimeCrash =
1583- !handled && log_looks_like_runtime_crash (rr, runtimeLog);
1558+ !handled &&
1559+ vix::cli::errors::RawLogDetectors::hasAuthoritativeRuntimeEvidence (
1560+ runtimeLog,
1561+ evidence);
15841562
15851563 if (maybeRuntimeCrash)
15861564 {
15871565 handled = vix::cli::errors::RawLogDetectors::handleRuntimeCrash (
15881566 runtimeLog,
15891567 state.script ,
1590- " Script execution failed" );
1568+ " Script execution failed" ,
1569+ evidence);
15911570
15921571 if (!handled &&
15931572 vix::cli::errors::RawLogDetectors::handleKnownRunFailure (runtimeLog, state.script ))
@@ -1642,13 +1621,19 @@ namespace vix::commands::RunCommand::detail
16421621 log += rr.stdoutText ;
16431622
16441623 bool handled = false ;
1624+ const vix::cli::errors::RuntimeCrashEvidence evidence{
1625+ rr.terminatedBySignal ,
1626+ rr.termSignal };
16451627
1646- if (!log.empty ())
1628+ if (vix::cli::errors::RawLogDetectors::hasAuthoritativeRuntimeEvidence (
1629+ log,
1630+ evidence))
16471631 {
16481632 handled = vix::cli::errors::RawLogDetectors::handleRuntimeCrash (
16491633 log,
16501634 state.script ,
1651- " Script execution failed" );
1635+ " Script execution failed" ,
1636+ evidence);
16521637
16531638 if (!handled &&
16541639 vix::cli::errors::RawLogDetectors::handleKnownRunFailure (log, state.script ))
@@ -2518,13 +2503,19 @@ namespace vix::commands::RunCommand::detail
25182503 if (exitCode != 0 )
25192504 {
25202505 bool handled = false ;
2506+ const vix::cli::errors::RuntimeCrashEvidence evidence{
2507+ WIFSIGNALED (status),
2508+ WIFSIGNALED (status) ? WTERMSIG (status) : 0 };
25212509
2522- if (!runtimeLog.empty ())
2510+ if (vix::cli::errors::RawLogDetectors::hasAuthoritativeRuntimeEvidence (
2511+ runtimeLog,
2512+ evidence))
25232513 {
25242514 handled = vix::cli::errors::RawLogDetectors::handleRuntimeCrash (
25252515 runtimeLog,
25262516 script,
2527- label + " exited with code " + std::to_string (exitCode));
2517+ label + " exited with code " + std::to_string (exitCode),
2518+ evidence);
25282519
25292520 if (!handled &&
25302521 vix::cli::errors::RawLogDetectors::handleKnownRunFailure (runtimeLog, script))
0 commit comments