Skip to content

Commit 3864b16

Browse files
author
Peter Szabo
committed
added using of _exit on fatal errors; workaround for pts#61
1 parent 2f03331 commit 3864b16

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

error.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include "error.hpp"
1414
#include "gensio.hpp"
1515
#include <stdio.h>
16-
#include <stdlib.h> /* exit() */
16+
#include <stdlib.h> /* exit(), _exit() in MinGW */
1717
#include <string.h> /* strlen() */
18+
#include <unistd.h> /* _exit() on Linux */
1819
#if _MSC_VER > 1000
1920
# include "windows.h" /* ExitThread() */
2021
#endif
@@ -88,8 +89,17 @@ GenBuffer::Writable& operator <<(GenBuffer::Writable& err,Error*) {
8889
if (NULLP!=p->record) Error::policy_top->err->vi_write(p->record->begin_(), p->record->getLength());
8990
p=p->next;
9091
}
91-
// if (level>=Error::policy_top->killer)
92-
Error::cexit(level);
92+
/* __SANITIZE_ADDRESS__ indicates g++ -fsanitize=address. This feature
93+
* detects memory leaks, and since sam2p is full of memory leaks on
94+
* fatal errors, we don't want them reported. With _exit() and abort(),
95+
* -fsanitize=address doesn't report memory leaks.
96+
*/
97+
#if (USE_UEXIT_ON_FATAL_ERROR || __SANITIZE_ADDRESS__) && !(_MSC_VER > 1000)
98+
_exit(level);
99+
#else
100+
// if (level>=Error::policy_top->killer)
101+
Error::cexit(level);
102+
#endif
93103
}
94104
/* Note that the order of error messages might be scrambled, i.e `printed'
95105
* is printed before `recorded'.

0 commit comments

Comments
 (0)