Skip to content

Commit 120ff02

Browse files
ktopley-applerokhinip
authored andcommitted
Workaround for Ubuntu 18.04 clang crashes in swift-corelibs-libdispath
rdar://problem/49023449 Signed-off-by: Kim Topley <ktopley@apple.com>
1 parent 86ec7b6 commit 120ff02

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/init.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
#include "protocolServer.h"
3030
#endif
3131

32+
#ifdef __linux__
33+
// The clang compiler in Ubuntu 18.04 has a bug that causes it to crash
34+
// when compiling _dispatch_bug_kevent_vanished(). As a workaround, use a
35+
// less capable version of this function on Linux until a fixed version
36+
// of the compiler is available.
37+
#define RDAR_49023449 1
38+
#endif // __linux__
39+
3240
#pragma mark -
3341
#pragma mark dispatch_init
3442

@@ -964,6 +972,7 @@ _dispatch_continuation_get_function_symbol(dispatch_continuation_t dc)
964972
return dc->dc_func;
965973
}
966974

975+
#if HAVE_MACH
967976
void
968977
_dispatch_bug_kevent_client(const char *msg, const char *filter,
969978
const char *operation, int err, uint64_t ident, uint64_t udata,
@@ -1007,6 +1016,23 @@ _dispatch_bug_kevent_client(const char *msg, const char *filter,
10071016
msg, strerror(err), err, udata, filter, ident, ident, func);
10081017
}
10091018
}
1019+
#endif // HAVE_MACH
1020+
1021+
#if RDAR_49023449
1022+
1023+
// The clang compiler on Ubuntu18.04 crashes when compiling the full version of
1024+
// this function. This reduced version avoids the crash but logs less useful
1025+
// information.
1026+
void
1027+
_dispatch_bug_kevent_vanished(dispatch_unote_t du)
1028+
{
1029+
_dispatch_log_fault("LIBDISPATCH_STRICT: _dispatch_bug_kevent_vanished",
1030+
"BUG in libdispatch client: %s, monitored resource vanished before "
1031+
"the source cancel handler was invoked",
1032+
dux_type(du._du)->dst_kind);
1033+
}
1034+
1035+
#else // RDAR_49023449
10101036

10111037
void
10121038
_dispatch_bug_kevent_vanished(dispatch_unote_t du)
@@ -1036,6 +1062,8 @@ _dispatch_bug_kevent_vanished(dispatch_unote_t du)
10361062
du._du->du_ident, du._du->du_ident, func);
10371063
}
10381064

1065+
#endif // RDAR_49023449
1066+
10391067
DISPATCH_NOINLINE DISPATCH_WEAK
10401068
void
10411069
_dispatch_bug_deprecated(const char *msg)

src/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,12 @@ void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
487487

488488
struct dispatch_unote_class_s;
489489

490+
#if HAVE_MACH
490491
DISPATCH_NOINLINE DISPATCH_COLD
491492
void _dispatch_bug_kevent_client(const char *msg, const char *filter,
492493
const char *operation, int err, uint64_t ident, uint64_t udata,
493494
struct dispatch_unote_class_s *du);
495+
#endif // HAVE_MACH
494496

495497
DISPATCH_NOINLINE DISPATCH_COLD
496498
void _dispatch_bug_kevent_vanished(struct dispatch_unote_class_s *du);
File renamed without changes.

0 commit comments

Comments
 (0)