Commit Graph

12522 Commits

Author SHA1 Message Date
Maxim Moiseev
caac1bf850 [overlay] Size the os_log pack buffer appropriately
Fixes: rdar://problem/31799909
2019-02-07 14:19:07 -08:00
Michael Ilseman
9bc5bd26e4 Merge pull request #22417 from milseman/null_and_void
[String] Fix crash when given null UBP
2019-02-07 10:46:01 -08:00
John McCall
f143db7942 Merge pull request #22409 from rjmccall/init-class-metadata-dependencies-compiler
Fix a race condition with the initialization of class metadata
2019-02-07 12:59:39 -05:00
swift-ci
998d9c4b1e Merge pull request #22430 from milseman/whoops 2019-02-06 18:06:26 -08:00
Andrew Trick
fa952d3986 Merge pull request #22338 from atrick/speedup-ubp-subscript
Remove useless optional unwrap from Unsafe[Raw]BufferPointer subscript.
2019-02-06 15:29:00 -08:00
Michael Ilseman
a742a62c18 [String] Use the new value in utf8 setter.
ð
2019-02-06 15:11:17 -08:00
Michael Ilseman
877a20ead0 [String] Fix crash when given null UBP 2019-02-06 14:44:01 -08:00
Daniel Rodríguez Troitiño
fe82b3e012 [cmake] Recover original CMAKE_C/CXX_COMPILER after changing them.
Seems that the change in the two variables was spilling into the other
target of the file, but returning it back to the original values seems
to avoid that issue.

This should unbreak the Android CI build. In it, the Linux static
library was changing to the host compiler, and that compiler was being
used for the Android runtime library, which would have never compile
that way (since the host compiler in CI is an old-ish Clang without the
necessary argument).
2019-02-06 14:43:48 -08:00
John McCall
79d15816c4 Fix a race condition with the initialization of class metadata.
In our initial approach for resolving metadata dependency cycles with classes, non-transitively complete superclass metadata was fetched by the subclass's metadata completion function and passed to `swift_initClassMetadata`. That could mean generating quite a lot of code in the completion function, and so we fairly recently changed it so that `swift_initClassMetadata` instead fetched the superclass metadata via a demangling. Unfortunately, the metadata demangler only fetches _abstract_ metadata by default, and class metadata cannot be considered even non-transitively complete when its superclass reference not at that stage.  If the superclass metadata is being completed on one thread, and a subclass is being completed on another, and the subclass installs the incomplete superclass metadata in its superclass field and attempts to register the subclass with the Objective-C runtime, the runtime may crash reading the incompletely-initialized superclass.

The proper fix is to make `swift_initClassMetadata` fetch non-transitively complete metadata for the superclass, delaying completion if that metadata is unavailable. Unfortunately, that can't actually be implemented on top of `swift_initClassMetadata` because that function has no means of reporting an unsatisfied dependency to its caller, and we can no longer simply change its signature without worrying about a small of internal code that might still be using it. We cannot simply perform a blocking metadata request in `swift_initClassMetadata` because it is deeply problematic to block within a metadata completion function. The solution is therefore to add a `swift_initClassMetadata2` which has the ability to report unsatisfied dependencies. That was done in #22386; this patch builds on that by teaching the compiler to generate code to actually use it. It is therefore not safe to use this patch if you might be running on an OS that only provides the old runtime function, but that should be a temporary Apple-internal problem.

Fixes rdar://47549859.
2019-02-05 23:28:57 -05:00
John McCall
3d50622223 Fix a bug with demangling reference storage that I just introduced.
Somehow this only broke tests on the 5.0 branch.
2019-02-05 23:26:33 -05:00
John McCall
2e252e174e Merge pull request #22386 from rjmccall/init-class-metadata-depedencies-runtime
Add new runtime functions for handling dependencies when initializing class metadata
2019-02-05 19:08:01 -05:00
Scott Perry
45522918ec Header docs for internal methods validateChanges(_:) and init(validatedChanges:) 2019-02-05 14:34:27 -08:00
Michael Gottesman
0cd01eb9e1 Merge pull request #22385 from gottesmm/pr-af26f08a0904c49030b0c365d8e3e69d15e79833
[cmake] Rather than using CMAKE_{C,CXX}_COMPILER and CMAKE_{C,CXX}_CO…
2019-02-05 14:28:08 -08:00
John McCall
a074bc2ed4 Add new APIs for init/updateClassMetadata that can report dependencies. 2019-02-05 16:44:56 -05:00
Michael Ilseman
d376a0f9c9 Merge pull request #21077 from linux-on-ibm-z/s390x-smallstring-v2
[string] Fix string implementation for big endian platforms
2019-02-05 13:36:05 -08:00
Michael Gottesman
f13b8eb10b [cmake] Rather than using CMAKE_{C,CXX}_COMPILER and CMAKE_{C,CXX}_COMPILER_ARG1 for distcc, use CMAKE_{C,CXX}_COMPILER_LAUNCHER.
This is a cleaner, more principled way of adding "compiler launcher" support and
ensures that cmake understands that distcc is not the "actual" compiler.

This ensures that when we compile SwiftRemoteMirrors for the host, we do not try
to compile using distcc without needing to reset CMAKE_{C,CXX}_COMPILER_ARG1
(which is unset when compiling things in the stdlib).
2019-02-05 13:22:53 -08:00
John McCall
d07efd37e0 Requestify the mangling-to-metadata APIs.
Note that I've called out a couple of suspicious places where we
are requesting abstract metadata for superclasses but probably
need to be requesting something more complete.
2019-02-05 16:20:48 -05:00
John McCall
de4564877a Separate CC attrs in the compatibility-override macro; NFC. 2019-02-05 16:20:48 -05:00
Ben Rimmington
7c65c14df7 [stdlib] Fix memory leaks in readLine()
<https://bugs.swift.org/browse/SR-6127>
2019-02-05 03:43:00 +00:00
swift-ci
0007eafb49 Merge pull request #22255 from compnerd/where-are-thou-implib 2019-02-04 19:14:05 -08:00
Scott Perry
b7f36c3399 Include renamed CollectionDifference.swift 2019-02-04 15:37:22 -08:00
Saleem Abdulrasool
0a1abdccfc build: attempt to repair Windows debug builds
The debug build of the standard library on Windows does not generate the
import library for SwiftOnoneSupport which prevents the build of debug
programs against the debug runtime.  Because the linker must find the
import library in order to satisfy the forced link that we emit for the
link against the SwiftOnoneSupport library, without this, the build is
not usable.  Furthermore, this requires a debug build of the runtime
since in the optimized build, the interfaces that this library provides
are not provided by swiftCore and this supplements the library to allow
building the debug program.
2019-02-04 15:13:46 -08:00
fredriss
b6077176ee Merge pull request #21904 from compnerd/mirror-mirror-on-the-wall
SwiftRemoteMirror: add a host build for the tools
2019-02-04 14:56:42 -08:00
Scott Perry
b467e24a9e Apply public documentation and type modifications from proposal acceptance 2019-02-04 13:28:36 -08:00
Jordan Rose
b0f5815d2b Merge pull request #20951 from pitiphong-p/encoders-nested-key-edge-case-bug
Reuse the container when requesting for a new nested container with the old key in JSONEncoder and PlistEncoder
2019-02-04 13:19:42 -08:00
Andrew Trick
a557976f95 Remove useless optional unwrap from Unsafe[Raw]BufferPointer subscript.
It is unfortunate that `Unsafe[Raw]BufferPointer._pointer` and
`baseAddress` are declared Optional. This leaves extra runtime checks
in the code in the most performance critical paths. Contrast this with
Array, which uses an sentinal pointer for the empty representation.

This forces us to use _unsafelyUnwrappedUnchecked whenever we just
want to dereference a non-empty buffer pointer.

Fixes SR-9809: swiftc appears to make some sub-optimal optimization choices
2019-02-03 21:25:41 -08:00
Saleem Abdulrasool
d4660ef8c2 Windows: extend WinSDK module further
This extends the WinSDK modulemap to cover Winsock2 and IPHelp API Set.
These are used in Foundation.
2019-02-02 18:50:20 -08:00
Lily Vulcano
337904fb2e Merge pull request #22311 from millenomi/fix_kvo-take-2
Take 2 of “[SDK] Fix multiple issues with Swift KVO”
2019-02-01 17:18:53 -08:00
Mishal Shah
cc78af105f Merge pull request #22274 from apple/update-master-xcode-10.2-beta-1
Update master to build with Xcode 10.2 beta 1
2019-02-01 16:30:58 -08:00
Ben Cohen
95a15d12bd Revert count(where:) (#22289) 2019-02-01 15:05:06 -08:00
Max Moiseev
91d8615cb9 Merge pull request #22275 from airspeedswift/unsafe-conversion
[stdlib] Restore concrete initializers on Unsafe{Raw}Pointer
2019-02-01 15:04:55 -08:00
Lily Vulcano
bdb4686375 Take 2 of “[SDK] Fix multiple issues with Swift KVO”
This reproposes @lilyball’s fixes in https://github.com/apple/swift/pull/20103 while adding her fix to ensure observations are removed before observed objects in 32-bit testing.
2019-02-01 14:07:44 -08:00
Joe Shajrawi
596dfd9dfb Merge pull request #22297 from millenomi/revert-fix_kvo
Simulator build fix — (temporarily) revert "Merge pull request #20103 from lilyball/fix_kvo"
2019-02-01 13:02:56 -08:00
Max Moiseev
556e089d19 Merge pull request #22138 from moiseev/spring-cleaning
[stdlib] Remove a bunch of declarations marked as obsoleted in 4
2019-02-01 11:03:37 -08:00
Lily Vulcano
ac7a93963c Revert "Merge pull request #20103 from lilyball/fix_kvo"
This reverts commit 7c514196fc, reversing
changes made to 2d7c31b24c.

This patch will be reproposed with fixes.
2019-02-01 10:55:06 -08:00
Ben Cohen
c3239b90b4 Neaten breadcrumb cast 2019-01-31 21:09:40 -08:00
Ben Cohen
779ea19a6a Revert count(where:) 2019-01-31 18:57:17 -08:00
Ben Cohen
2010f02e8a Remove overly-permissive UnsafePointer init 2019-01-31 18:05:11 -08:00
Ben Cohen
351c1291a9 Restore concrete initializers on Unsafe{Raw}Pointer 2019-01-31 17:11:16 -08:00
Mishal Shah
42633218c5 Update master to build with Xcode 10.2 beta 1 2019-01-31 14:48:29 -08:00
Maxim Moiseev
714982bd1b Remove access specifiers on some extensions to avoid warnings 2019-01-31 14:36:55 -08:00
Maxim Moiseev
8f5877b994 Fix INParameter availability 2019-01-31 13:43:19 -08:00
Max Moiseev
5da70012db Merge pull request #22244 from moiseev/macos-inimage
Make APIs using INImage unavailable on macOS
2019-01-30 15:53:27 -08:00
Lily Vulcano
b864a7461f Rebase master; move this to use NSSet, not AnyObject. 2019-01-30 13:06:02 -08:00
Lily Ballard
4dd8bcc548 [SDK] Clean up the KVO swizzles slightly 2019-01-30 12:41:14 -08:00
Lily Ballard
fafaa33f9b [SDK] Replace global KeyPath table with a per-thread table
The global table was vulnerable to race conditions when making
observations concurrently on multiple threads. We can assume the
`NSKeyValueObservingCustomization` methods are invoked synchronously
when creating the observation, so we can use a per-thread table instead.
This per-thread table is still vulnerable in the event that an
implementation of `automaticallyNotifiesObservers(for:)` creates a new
observation using a different `KeyPath` with the same Obj-C path, but
this method really shouldn't be creating any observations of its own.

Unfortunately we can't include the class in the per-thread table key, as
this may produce incorrect results in the presence of subclasses.

rdar://problem/45567020 https://bugs.swift.org/browse/SR-9077
2019-01-30 12:41:14 -08:00
Lily Ballard
e5ba2c8356 [SDK] Fix NSSortDescriptor.keyPath
The previous implementation could return keyPaths other than the one
used to create the `NSSortDescriptor` in the event that any subsequent
observation, `NSExpression`, or `NSSortDescriptor` was created using a
different `KeyPath` that had the same Obj-C keypath value.

https://bugs.swift.org/browse/SR-9076
2019-01-30 12:41:13 -08:00
Lily Ballard
82e3171556 [SDK] Fix potential race with NSKeyValueObservation
If the `NSKeyValueObservation` was being deinited on one thread while a
KVO change notice was being broadcast on another, it could end up trying
to handle the change notice concurrently with deiniting, which will
probably crash.

This also fixes a problem where it was swizzling `NSObject`'s
`observeValue(forKeyPath:of:change:context:)` implementation, which
resulted in potentially invoking undefined behavior if an observer ever
called up to `NSObject`'s implementation.

https://bugs.swift.org/browse/SR-9074
https://bugs.swift.org/browse/SR-9075
2019-01-30 12:41:13 -08:00
Lily Ballard
dd51e9d4bb [SDK] Fix thread safety of KVO swizzling
Swizzling the methods in a different order ensures we don't overwrite
the public `NSObject` method until it's safe to call our replacement.

rdar://problem/36663633 https://bugs.swift.org/browse/SR-6795
2019-01-30 12:41:13 -08:00
Maxim Moiseev
af00487bb8 Make APIs using INImage unavailable on macOS
<rdar://problem/47673006>
2019-01-30 11:10:32 -08:00