Skip to content

Commit f03fa15

Browse files
committed
Workaround for Ubuntu 18.04 clang crashes in swift-corelibs-libdispath
rdar://problem/49023449
1 parent 7a74af4 commit f03fa15

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Diff for: src/init.c

+29-1
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

@@ -955,6 +963,7 @@ _dispatch_continuation_get_function_symbol(dispatch_continuation_t dc)
955963
return dc->dc_func;
956964
}
957965

966+
#if HAVE_MACH
958967
void
959968
_dispatch_bug_kevent_client(const char *msg, const char *filter,
960969
const char *operation, int err, uint64_t ident, uint64_t udata,
@@ -998,6 +1007,23 @@ _dispatch_bug_kevent_client(const char *msg, const char *filter,
9981007
msg, strerror(err), err, udata, filter, ident, ident, func);
9991008
}
10001009
}
1010+
#endif // HAVE_MACH
1011+
1012+
#if RDAR_49023449
1013+
1014+
// The clang compiler on Ubuntu18.04 crashes when compiling the full version of
1015+
// this function. This reduced version avoids the crash but logs less useful
1016+
// information.
1017+
void
1018+
_dispatch_bug_kevent_vanished(dispatch_unote_t du)
1019+
{
1020+
_dispatch_log_fault("LIBDISPATCH_STRICT: _dispatch_bug_kevent_vanished",
1021+
"BUG in libdispatch client: %s, monitored resource vanished before "
1022+
"the source cancel handler was invoked",
1023+
dux_type(du._du)->dst_kind);
1024+
}
1025+
1026+
#else // RDAR_49023449
10011027

10021028
void
10031029
_dispatch_bug_kevent_vanished(dispatch_unote_t du)
@@ -1012,7 +1038,7 @@ _dispatch_bug_kevent_vanished(dispatch_unote_t du)
10121038
dc = du._dr->ds_handler[DS_EVENT_HANDLER];
10131039
if (dc) func = _dispatch_continuation_get_function_symbol(dc);
10141040
break;
1015-
#if HAVE_MACH
1041+
#if HAVE_MACH
10161042
case DISPATCH_MACH_CHANNEL_TYPE:
10171043
func = du._dmrr->dmrr_handler_func;
10181044
break;
@@ -1027,6 +1053,8 @@ _dispatch_bug_kevent_vanished(dispatch_unote_t du)
10271053
du._du->du_ident, du._du->du_ident, func);
10281054
}
10291055

1056+
#endif // RDAR_49023449
1057+
10301058
DISPATCH_NOINLINE DISPATCH_WEAK
10311059
void
10321060
_dispatch_bug_deprecated(const char *msg)

Diff for: src/internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,12 @@ void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
474474

475475
struct dispatch_unote_class_s;
476476

477+
#if HAVE_MACH
477478
DISPATCH_NOINLINE DISPATCH_COLD
478479
void _dispatch_bug_kevent_client(const char *msg, const char *filter,
479480
const char *operation, int err, uint64_t ident, uint64_t udata,
480481
struct dispatch_unote_class_s *du);
482+
#endif // HAVE_MACH
481483

482484
DISPATCH_NOINLINE DISPATCH_COLD
483485
void _dispatch_bug_kevent_vanished(struct dispatch_unote_class_s *du);

0 commit comments

Comments
 (0)