Commit Graph

7 Commits

Author SHA1 Message Date
Slava Pestov
c98ce0c770 IRGen: Fix Dispatch overlay for non-optimized builds
I apologize in advance to @jrose-apple, who is not a fan
of this fix ;-)

In unoptimized builds, the convenience initializers on
DispatchQueue allocate and immediately deallocate an
instance of OS_dispatch_queue prior to calling the
C function that returns the "real" instance.

This is because we don't have a way to write user-defined
factory initializers yet; convenience initializers still
have an 'initializing' entry point that takes an existing
instance, which we have no choice but to throw away.

Unfortunately, when we perform the fake allocation, we
look up class metadata by calling the wrong Swift runtime
function, causing a crash when we send +allocWithZone:.

Fix this so that the metadata is accessed via a lookup
from the Objective-C runtime, instead of making a totally
fake 'foreign metadata' object -- it looks like there was
code for this already, it just wasn't used in all cases.

While getting metadata for a runtime-only class should be
rare, this feels like a real bug fix, to me.

Second, we would ultimately free the fake object by sending
-release, however OS_dispatch_queue has an override of
-dealloc which doesn't like to be called with a completely
uninitialized instance.

Here, I'm going to drop all pretense of sanity. The patch
just changes IRGen to lower the dealloc_partial_ref instruction
as a call to the object_dispose() Objective-C runtime function
when the class in question is a runtime-only class. This
frees the object without running -dealloc, which *happens*
to work for OS_dispatch_queue.

Fixes <rdar://problem/27226313>.
2016-08-13 01:51:45 -07:00
Matt Wright
f714ff5fc1 [libdispatch] fixup tests for new syntax
* Several swift tests rely on old libdispatch syntax. This change
    adopts the new syntax throughout the swift tests.
2016-07-18 13:22:23 -07:00
Ben Langmuir
42ac1cb41b Disable Runtime/weak-reference-racetests-dispatch with debug stdlib
This configuration is breaking CI.  It should be reenabled by
rdar://problem/27226313.
2016-07-18 09:49:56 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Joe Pamer
5b349f84f4 Harden one test against potential future type checker experiments. 2016-05-06 12:41:57 -07:00
Guillaume Lessard
2b189f18e8 [test] eliminate a workaround made redundant by 49c5487 2016-05-04 16:24:55 -06:00
Guillaume Lessard
c87309eb4d [test] Tests for weak reference read-read thread safety
Dispatch-based tests exist because (on OS X) they are more likely to encounter the race condition than `StdlibUnitTest`'s `runRaceTest()` is.
2016-05-03 20:58:44 -06:00