Commit Graph

254 Commits

Author SHA1 Message Date
Karl Wagner
ab4f80ed95 [SE-0404] Allow protocols to be nested in non-generic contexts 2023-10-06 21:04:03 +02:00
Kavon Farvardin
54e5205194 Merge pull request #68600 from kavon/optional-try-coercion-bug-v2
[SILGen] fix SR-14882: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
2023-09-19 09:42:04 -07:00
Kavon Farvardin
583f127de7 fix [SR-14882]: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
The problem was that in the by-address emission, we were calling
 `getAddressForInPlaceInitialization` twice, triggering the assert.

The first time in `emitExprInto` for the normal result case.

The second time to obtain the address again when generating the
catch block to inject a `.none` into that same address.

This patch does a light refactoring to more closely mirror
`visitOptionalEvaluationExpr`, which avoids calling the asserting method.

fixes rdar://80277465
2023-09-18 15:41:43 -07:00
Alejandro Alonso
80187e8096 Expect caller heap pack and rename
Fix comment
2023-09-06 21:37:00 -07:00
Alejandro Alonso
3dbad6e1fd Add a runtime function to check type creation 2023-09-06 11:32:22 -07:00
Mike Ash
b249d3bea5 [Test] Reenable disabled test in associated_type_demangle_private.swift.
This was disabled due to a weird failure on iOS 10, which is no longer a supported target.

rdar://97996884
2023-07-14 15:38:46 -04:00
Daniel Rodríguez Troitiño
8f0382c109 [test] Replace swift_obj_root for alternates that work in LLVM unified builds (#66167)
In LLVM unified builds `%swift_obj_root` points to `<LLVM build dir>/tools/swift`,
and folders like `bin`, `lib` and `share` are not under `swift_obj_root`, which
makes some tests fail.

For the cases in which `%swift_obj_root/lib` was used, replace it by
using `%swift-lib-dir` instead. Replicate `%swift-lib-dir` to create
`%swift-bin-dir` and `%swift-share-dir`, and use those instead of
`%swift_obj_root/bin` and `%swift_obj_root/share`.

This alternates work both in Swift build-script builds and also in LLVM
unified builds.
2023-05-26 08:39:31 -07:00
swift-ci
eaf53dfee2 Merge pull request #65107 from mikeash/reenable-custom-rr-test
[Test] Reenable custom_rr_abi.swift.
2023-05-12 11:22:17 -07:00
Mike Ash
17c32f4997 [Test] Reenable custom_rr_abi.swift.
CI has updated macOS and we should no longer have the issue of dyld stubs using our nonstandard argument registers.

rdar://102912772
2023-05-11 17:30:55 -04:00
Yuta Saito
a9998653e9 [Test] Disable concurrent test under single thread assumption 2023-04-29 13:47:24 +00:00
Alastair Houghton
9833e09b58 [Tests] Disable path lookup test for OS stdlib.
Path lookup needs the new stdlib.

rdar://107399270
2023-03-30 09:39:40 +01:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Saleem Abdulrasool
9df349e0da test: adjust Runtime Paths test for unified builds
When building the toolchain in unified mode, we fail to search for
headers and libraries.  Adjust the invocation to account for the layout
differences.
2023-03-09 13:33:22 -08:00
Alastair Houghton
fdb010433d [Remote Test] Fix remote-run to process environment variables.
`remote-run` should look in the environment for input/output paths as
well as considering command line arguments.

With this change, `test/Runtime/Paths.cpp` should work for remote testing
and device testing.

rdar://106294557
2023-03-07 16:01:10 +00:00
Alastair Houghton
35a2f17d35 [Backtracing] Add missing void cast to the paths test.
We need to cast in order to call `free()`.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
69bad8cb09 [Backtracing] Rename a couple of functions, some comment changes.
Renamed a couple of functions following review feedback.  Also added some
extra words to the comments.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
f02f62f1e3 [Backtracing] Add support for looking up paths for auxiliary executables.
We need to be able to locate `swift-backtrace` relative to the current
location of the runtime library.

This needs to work:

* In a Swift build directory.
* On Darwin, where we're installed in /usr/lib/swift and /usr/libexec/swift.
* On Linux, where we're in /usr/lib/swift/linux and /usr/libexec/swift/linux.
* On Windows, where we may be in a flat directory layout (because of limitations
  of Windows DLL lookups).

rdar://103071801
2023-03-01 13:43:15 +00:00
Mike Ash
80bb78d01d [Test] Change the -target line on some tests to use a minimum of macOS 10.13.
These tests were targeting 10.9 or 10.10, but the minimum deployment target now supported by Xcode is 10.13. Bump them up to match:

test/Concurrency/Backdeploy/linking.swift
test/Concurrency/Backdeploy/linking_maccatalyst.swift
test/Runtime/stable-bit-backward-deployment.swift
2023-02-21 13:48:33 -05:00
Mike Ash
591e3a371c [Test] Fix deinit_escape test.
When compiled with optimizations, the compiler saw that C() doesn't escape and stack promoted it, which breaks the check. Deliberately escape the object into a global array beforehand to ensure it has to be on the heap.

rdar://103369708
2022-12-15 13:22:28 -05:00
Mike Ash
108f7805e5 [Runtime] Fatal error if self escapes from deinit.
When deallocating a class instance, we check the retain count of the instance and error if it's greater than 1.

Self is allowed to be temporarily passed to other code from deinit, but there's no way to extend the lifetime of the object. Retaining it no longer extensd the lifetime. If self escapes from deinit, the result is a dangling pointer and eventual crash.

Instead of crashing randomly due to a dangling pointer, crash deliberately when destroying an object that has escaped.

rdar://93848484
2022-12-07 12:42:41 -05:00
Evan Wilde
d01760a4df Disable custom_rr_abi.swift
Failing in Swift Incremental RA - macOS - Apple Silicon

https://ci.swift.org/job/oss-swift-incremental-RA-macos-apple-silicon/2266/

```
[ RUN      ] CustomRRABI.retain
stderr>>> CRASHED: SIGSEGV
the test crashed unexpectedly
[     FAIL ] CustomRRABI.retain
CustomRRABI: Some tests failed, aborting
UXPASS: []
FAIL: ["retain"]
SKIP: []
To debug, run:
$ /Users/ec2-user/jenkins/workspace/oss-swift-incremental-RA-macos-apple-silicon/build/buildbot_incremental/swift-macosx-arm64/test-macosx-arm64/Runtime/Output/custom_rr_abi.swift.tmp/a.out --stdlib-unittest-in-process --stdlib-unittest-filter "retain"
```

rdar://102912772
2022-12-02 11:47:36 -08:00
Mike Ash
fefe33fd7d [Runtime] Add missing bridgeObjectRR_xN entrypoints.
We're supposed to expose bridgeObjectRetain/Release_xN variants, but they were missing. This fixes the custom_rr_abi.swift test. Also remove the redundant extern "C" on the entrypoint definitions, which fixes some warnings.

rdar://102793667 rdar://102783074
2022-11-30 10:50:14 -05:00
Mike Ash
58a519a5c1 [Test] Disable custom_rr_abi test until we can fix it. (#62304) 2022-11-29 14:07:37 -08:00
Mike Ash
b677b5676a [Runtime] Add register-specific entrypoints for retain/release calls on ARM64.
This will allow emitted code to condense a sequence like:

    mov x0, x21
    bl swift_retain

To:

    bl swift_retain_x21

Saving code size.

rdar://98884198
2022-11-15 09:53:49 -05:00
Mike Ash
f8e8fa0dc8 [Test] Re-fix Runtime/protocol_conformance_collision.swift.
rdar://98989894
2022-10-07 12:42:45 -04:00
Evan Wilde
64b19f7f45 Backdeploy task_wait_future fix to Swift 5.6 (#61254)
* Backdeploy swift_task_future_wait

This patch adds the implementation for `swift_task_future_wait`
entrypoint to the backdeploy library.

This involves pulling in `AsyncTask::waitFuture`, which relies on a fair
bit.

Please note, this pulls in the `StaticMutex` implementation from Swift
5.6. There are some challenges here. The concurrency version of the
`StaticMutex` involves a fairly nasty set of ODR violations in the
normal setup. See `public/Concurrency/Mutex.cpp`, which includes the
Mutex implementations cpp files directly, while defining a single macro
to replace the implementation of swift::fatalError with
swift_concurrency_fatalError. We only need the concurrency mutex (at
least for now), so I have hard-coded the `swift_concurrency_fatalError`
version into this library. If we should need the other implementation,
we are forced to include ODR-related undefined behavior.

We need symbols from C++, so I've added an implicit linker flag whenever
the static library is used, namely, it passes `-lc++` to the linker.
Since we only backdeploy on Apple platforms, this should be fine.

Some of the platform runtimes we need to backdeploy to have the
enter/exitThreadLocalContext functions defined, while others don't. We
define our own backdeploy56 shim function that dlsym's the function
pointer for these symbols if we have exclusivity checking available.
Otherwise, it doesn't do anything. If concurrency exclusivity checking
is available, we'll use it, otherwise we wont'.

The same dlsym check is done for `swift_task_escalate`. Not all
platforms we need to backdeploy to have a concurrency runtime. The
symbols that do need to use pieces of the concurrency runtime should not
be getting hit when deploying to systems that don't have concurrency. In
the event that you've gotten around the language blocking you from
calling these symbols and you've managed to call concurrency pieces
without using concurrency, we'll abort because something is seriously
wrong.

* Backdeploy swift_task_future_wait_throwing

Drop the remaining pieces in for adding
`swift_task_future_wait_throwing`.

* Apply task_wait_future fix

Actually apply the fix from ef80a315f8.

This deviates slightly from the original patch.

AsyncTask::PrivateStorage::_Status() does not exist in the Swift 5.6
library. Instead I am using `AsyncTask::PrivateStorage::Status`.

* Workaround missing compiler-rt linking

Working around the missing link against compiler-rt in these test.
They are a bit brittle as if anything in them uses compiler-rt, they
will start failing. The backdeploy 5.6 library uses some symbols from
compiler-rt, thus causes them to fail to link.

Disabling the runtime compatibility version checking to avoid these
symbols. This should be fine for the MicroStdlib test, but we should fix
'%target-ld' to handle this better in the future.
rdar://100868842
2022-10-07 09:36:17 -07:00
Mike Ash
ed7b7ca854 [Test] Don't test concurrentTypeByName.swift against old, unfixed runtimes. 2022-10-03 15:08:21 -04:00
Mike Ash
e15783ecd4 [Runtime] Fix concurrent lookups of types by name (again).
Fix a potential false positive if we check a class for a protocol conformance and its superclasses aren't yet instantiated.

This was partially fixed before, but we were incorrectly saying that all superclasses had been instantiated if they had been instatiated by the LAST check in conformsToProtocol. That left us open for a possible false positive in an earlier check to go unnoticed.

This change fixes it by checking for uninstantiated superclasses after each iteration over superclasses, not just the last one.

This change also makes the concurrentTypeByName test much more robust. The original test caught this bug only rarely, but the new one catches it it reliably. We now look up 1000 types per test run. Testing locally, we typically hit the race after less than 100 types.

rdar://82364236
2022-09-23 16:45:30 -04:00
Anthony Latsis
1b121e5527 Merge pull request #60921 from AnthonyLatsis/migrate-test-suite-to-gh-issues-18
Gardening: Migrate test suite to GH issues p. 18
2022-09-09 12:07:51 +03:00
Mike Ash
1220321756 [Test] Fix protocol_conformance_collision.swift.
Use 2021 OS versions instead of far-future OS versions. We have versions with the fix now, so we don't need the far-future versions. Using them breaks things when building against a newer SDK and running on an older OS, because the system assumes stuff on the newer OS is available when it isn't.
2022-09-02 12:16:01 -04:00
Anthony Latsis
4002bd5217 Gardening: Migrate test suite to GH issues: Runtime 2022-09-02 06:12:45 +03:00
Mike Ash
82e479896d [Test] Reenable associated_type_demangle_private.swift.
The "nested private generic types in associated type witnesses" test is failing in back-deployment tests. Disable that one test, and re-enable the rest.
2022-08-09 10:33:08 -04:00
Meghana Gupta
a8dbc5f40b Merge pull request #60365 from meg-gupta/disableruntimetest
Disable test associated_type_demangle_private.swift failing in CI
2022-08-03 09:49:06 -07:00
Meghana Gupta
18411bf116 Disable test associated_type_demangle_private.swift failing in CI 2022-08-02 15:05:07 -07:00
Mike Ash
5f5caebf04 [Test] Reenable "failed to demangle" portion of associated_type_demangle_private.swift.
This test was disabled a while ago but the problem seems to have been fixed sometime since then.

rdar://51959305
2022-07-29 15:05:36 -04:00
Mike Ash
91b86912e6 [Runtime] Fix rare crash when fixing up dynamic subclasses.
Swift vtables can contain NULL entries. This happens when the compiler is able to prove that a method is never called.

When ptrauth is enabled, those NULL entries are still signed. However, there's an inconsistency in the runtime. Most places where we copy a vtable with swift_ptrauth_copy_code_or_data, we accept an unsigned NULL value. But when fixing up a dynamic ObjC subclass with swift_objc_classCopyFixupHandler, we don't.

Since the compiler seems to always sign these NULL values, this still works, except in the case where a signed NULL value coincidentally has a ptrauth signature of all zeroes. When that happens, the code to accept an unsigned NULL value sees this NULL with an all-zero signature as an unsigned NULL, and copies it verbatim. Then we really do have an unsigned NULL in the destination.

If that class is then dynamically subclassed, we'll call swift_objc_classCopyFixupHandler which does not accept unsigned NULL values, and fail ptrauth.

Adjust swift_objc_classCopyFixupHandler to accept unsigned NULL like the rest. These entries should never be called, and any attempt to call them will crash regardless, so it makes little difference.

rdar://92800322
2022-07-25 22:38:55 -04:00
Yuta Saito
687dca9d60 [Threading][test] disable threaded lit tests under threading_none 2022-07-07 01:57:38 +00:00
Josh Soref
a01f6f8724 spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-01 04:32:22 -04:00
Mike Ash
e0d0af83d7 [Test] Make allocator_sanity.swift more robust on 32-bit.
This test attempts to allocate Int.max bytes and asserts that it crashes. However, this can actually succeed in (some) 32-bit environments, since Int.max is only 2^32-1 bytes there. This causes spurious test failures. Ensure the test crashes by making two gargantuan allocations.

rdar://91687691
2022-04-13 11:19:32 -04:00
Jonathan Grynspan
845182252c Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime. 2022-03-04 23:44:10 -05:00
Alastair Houghton
5cfa1aa22f Make the environment_variables test less flaky.
The test was inadvertently depending on the ordering of output between
stderr and stdout, which makes it break particularly when being run
remotely.

rdar://88335113
2022-02-16 15:53:34 +00:00
Michael Gottesman
9c982dc97f Disable linux backtrace test since it is failing now to unblock the bots.
rdar://87867848
2022-01-20 22:05:37 -08:00
Jonathan Grynspan
099fdc2e41 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2022-01-01 11:39:25 -05:00
Arnold Schwaighofer
cf3951394a Revert "Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.)" 2021-12-21 07:15:08 -08:00
Jonathan Grynspan
7fe5ea7398 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2021-12-20 15:15:02 -05:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07:00
Kavon Farvardin
e9836551dd disable concurrentTypeByName test to unblock CI 2021-08-25 16:52:00 -07:00
Guillaume Lessard
d03cb6daa1 [test] move two tests from from stdlib to runtime 2021-07-29 17:04:47 -06:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00