Skip to content

Commit f61366b

Browse files
committed
[Runtime] Make swift_unreachable more debuggable by trapping immediately.
Calling `abort` takes us a few layers deep into libc before we crash, which overwrites a bunch of register state. Instead, we trap directly within swift_unreachable, and mark it always-inline, to hopefully keep the full register state intact when we generate a crash log from this.
1 parent 2600aa5 commit f61366b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/swift/Basic/Unreachable.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535

3636
#include "swift/Runtime/Config.h"
3737

38-
SWIFT_RUNTIME_ATTRIBUTE_NORETURN
38+
SWIFT_RUNTIME_ATTRIBUTE_NORETURN SWIFT_ALWAYS_INLINE
3939
inline static void swift_unreachable(const char *msg) {
40-
assert(false && msg);
4140
(void)msg;
42-
abort();
41+
SWIFT_RUNTIME_BUILTIN_TRAP;
4342
}
4443

4544
#endif

0 commit comments

Comments
 (0)