summaryrefslogtreecommitdiff
path: root/rts/RtsMessages.c
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-01-07 12:47:07 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-01-11 19:44:33 -0500
commit7ca43a3fb315abf172a6f7ff2bb4cf4303017e24 (patch)
tree3c488faf681c0fe47954ff74c15edac20a74ee09 /rts/RtsMessages.c
parent19b13698f5afe6ab497eb2e2169cb9782a933f93 (diff)
downloadhaskell-7ca43a3fb315abf172a6f7ff2bb4cf4303017e24.tar.gz
Change assertions in Stats.c to warnings (and introduce WARN macro)
ASSERT should be used in situations where something very bad will happen later on if a certain invariant doesn't hold. The idea is that IF we catch the assertion earlier then it will be easier to work out what's going on at that point rather than at some indeterminate point in the future of the program. The assertions in Stats.c do not obey this philsophy and it is quite annoying if you are running a debug build (or a ticky compiler) and one of these assertions fails right at the end of your program, before the ticky report is printed out so you don't get any profiling information. Given that nothing terrible happens if these assertions are not true, or at least the terrible thing will happen in very close proximity to the assertion failure, these assertions use the new WARN macro which prints the assertion failure to stdout but does not exit the program. Of course, it would be better to fix these metrics to not trigger the assertion in the first place but if they did fail again in the future it is frustrating to be bamboozled in this manner. Fixes #20899
Diffstat (limited to 'rts/RtsMessages.c')
-rw-r--r--rts/RtsMessages.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/rts/RtsMessages.c b/rts/RtsMessages.c
index 9ecd831a83..8ece485854 100644
--- a/rts/RtsMessages.c
+++ b/rts/RtsMessages.c
@@ -73,6 +73,12 @@ errorBelch(const char*s, ...)
}
void
+_warnFail(const char*filename, unsigned int linenum)
+{
+ errorBelch("ASSERTION FAILED: file %s, line %u\n", filename, linenum);
+}
+
+void
verrorBelch(const char*s, va_list ap)
{
(*errorMsgFn)(s,ap);