Commit Graph

21434 Commits

Author SHA1 Message Date
Saleem Abdulrasool
6028fde00a Merge pull request #79116 from compnerd/silence
Concurrency: silence some unused variable warnings
2025-02-04 10:28:30 -08:00
Saleem Abdulrasool
0174528f81 stdlib: fix the problem swept under the rug in 58a97f1603
The `-Winvalid-offsetof` warning is valid in this case. `offsetof` is
being applied to types with a non-standard layout. The layout of this
type is undefined by the specification. There is no guarantee that the
type layout is uniform across all ABIs. It is not possible to portably
compute the offset statically, especially efficiently.

Sink this check into a unit test to avoid performing this test at
runtime. In order to do this in the standard library, we would need to
do this check through a global constructor.
2025-02-03 09:25:06 -08:00
Saleem Abdulrasool
8040430bc7 Concurrency: silence some unused variable warnings
This cleans up some warnings from the unused variables. The variables
were referenced by `assert` cases only.
2025-02-03 09:22:50 -08:00
Arnold Schwaighofer
d2d5ad6df4 Merge pull request #79111 from al45tair/eng/PR-144045984
[Backtracing] Local|RemoteMemoryReader only exists on macOS and Linux.
2025-02-03 08:36:53 -08:00
Alastair Houghton
615f884a42 Merge pull request #79057 from al45tair/backtracing-cxxstdlib-dep
[Backtracing] Add missing CxxStdlib dependency.
2025-02-03 16:26:55 +00:00
Alastair Houghton
a60dd8f76d [Backtracing] Local|RemoteMemoryReader only exists on macOS and Linux.
When fixing the previous problem, I should have realised that this
would cascade; the `@_specialize` annotations refer to the cached
versions of the types, and those are now turned off except on macOS
and Linux because they rely on the uncached versions, which are only
available on macOS and Linux.

rdar://144023438
2025-02-03 12:34:42 +00:00
Allan Shortlidge
4799f1e295 Concurrency: Suppress some warnings. 2025-02-01 13:52:43 -08:00
Allan Shortlidge
2b8d1be3ca Backtracing: Suppress a "switch covers known cases" warning. 2025-02-01 10:28:27 -08:00
Allan Shortlidge
e65aab74dd stdlib: Fix an unused variable warning. 2025-02-01 10:28:27 -08:00
Alastair Houghton
dd40b2f501 Merge pull request #79071 from al45tair/eng/PR-143869185
[Backtracing] Bump minimum deployment targets.
2025-02-01 10:28:14 +00:00
Arnold Schwaighofer
9b66fdf272 Merge pull request #79072 from al45tair/eng/PR-143865183
[Backtracing] Uncached(Local|Remote)MemoryReader only exists on macOS and Linux.
2025-01-31 16:02:04 -08:00
Philippe Hausler
854fa5c4e3 [Observation] Disable caching of KeyPaths (#78853)
* [Observation] Disable caching of KeyPaths

* Remove the cached keypath annottion for the ObservationTracked peer macro
2025-01-31 13:50:05 -08:00
Kuba (Brecka) Mracek
3afe8ebdf6 Merge pull request #78919 from kubamracek/embedded-dict-init
[embedded] Support Dictionary.init(uniqueKeysWithValues:) in Embedded Swift
2025-01-31 11:03:04 -08:00
Alastair Houghton
884cf75fb2 [Backtracing] Add missing CxxStdlib dependency.
To do this we also need to fix AddSwiftStdlib because if you set the
`INSTALL_WITH_SHARED` flag, the CMake scripts don't make a target
with the `-static` suffix, but AddSwiftStdlib also assumes that it
should dad `-static` to any module dependencies when building a
static library.
2025-01-31 14:52:48 +00:00
Alastair Houghton
6c7eda887e [Backtracing] Harden output path setting.
We should harden the output path setting so that it can't be used
as part of an exploit to get a crashing process to overwrite a
file at an attacker-controller path, or to divert the crash report
to `/dev/null` to hide their tracks or other such undesirable
activity.

Take a copy of the setting at start-up and write-protect it to
prevent attackers overwriting it.

Note that we already protect against attempts to trigger the
backtracer from privileged programs (both on Darwin and Linux);
this is really a belt and braces measure to make life harder for
attackers.

rdar://136977833
2025-01-31 14:36:56 +00:00
Alastair Houghton
5d9def94ad [Backtracing] Uncached(Local|Remote)MemoryReader only exists on macOS and Linux.
There's no support for this type on anything other than macOS and Linux
right now.

rdar://143865183
2025-01-31 14:22:31 +00:00
Alastair Houghton
857c96300f [Backtracing] Bump minimum deployment targets.
We need a minimum deployment target of 10.15 now, because of the use
of `some Sequence<T>` in the Runtime module interface.

rdar://143869185
2025-01-31 14:16:07 +00:00
Meghana Gupta
681a6c814a Merge pull request #78939 from meg-gupta/ossamoduleson
Enable serialization in OSSA
2025-01-30 23:25:19 -08:00
Dario Rexin
21c4850f6d Merge pull request #79031 from drexin/wip-143852239
[Runtime] Add specialized CVW entry points for multi payload enums
2025-01-30 21:45:09 -08:00
Kuba (Brecka) Mracek
38c0ce58aa Merge pull request #79055 from kubamracek/embedded-concurrency-libcxx
[embedded] Prepare the Embedded Concurrency library for building on armv7m/armv7em
2025-01-30 18:37:59 -08:00
Kuba (Brecka) Mracek
55d5a57963 Merge pull request #79054 from kubamracek/embedded-custom-triples
[embedded] Add a CMake setting for building Embedded Swift stdlib for custom target triples
2025-01-30 18:37:47 -08:00
Erik Eckstein
20db2a488b stdlib: add a missing fixLifetime in withVaList
If this function is inlined, the optimizer can shrink the lifetime of the `args` parameter. This would deallocate the passed arguments (e.g. `NSString`s) before the are used in the closure.
2025-01-30 17:30:22 -08:00
Dario Rexin
923cccf1ea [Runtime] Add specialized CVW entry points for multi payload enums
rdar://143852239

Adding these specialized entry points reduces the overhead of the witness functions by removing the first indirection.
2025-01-30 14:44:49 -08:00
Kuba Mracek
aea2bb563c [embedded] Prepare the Embedded Concurrency library for building on armv7m/armv7em 2025-01-30 10:48:09 -08:00
Kuba Mracek
0a678670cd [embedded] Add a CMake setting for building Embedded Swift stdlib for custom target triples 2025-01-30 10:43:59 -08:00
Saleem Abdulrasool
35cbb211c1 Distributed: silence some -Wcast-function-type-mismatch
This silences some of the newer warnings about the casting of function
pointers which is technically not permitted by the standard (function
and data pointers are not guaranteed to be the same).
2025-01-29 17:46:37 -08:00
Alejandro Alonso
0572eb9ef0 Merge pull request #78857 from Azoy/wordpair-comparable
[stdlib] Add Comparable conformance to WordPair
2025-01-29 11:20:56 -08:00
Saleem Abdulrasool
0e73015f96 Merge pull request #78985 from compnerd/central-dispatch
Concurrency: centralise the definition for `std::bit_cast`
2025-01-29 08:38:11 -08:00
Alastair Houghton
255a39573f [Backtracing] Handle EINTR while trying to create a crash log.
Mike rightly points out that it's possible for `open()` to fail
with `EINTR`, which we should handle here.

rdar://136977833
2025-01-29 16:15:38 +00:00
Alastair Houghton
9bdd9e73dc [Backtracing] Support redirection to a named file.
Add the ability to specify a filename or directory name as the output-to
setting in `SWIFT_BACKTRACE`.  If the option is set to a directory name,
generate a unique filename in that directory using the process name,
process ID and timestamp.

rdar://136977833
2025-01-29 10:20:15 +00:00
Gábor Horváth
8462105e29 Merge pull request #78947 from swiftlang/gaborh/lifetimebound-this 2025-01-29 09:09:53 +00:00
Kuba Mracek
642a8f9762 [embedded] #ifdef the Dictionary.init(uniqueKeysWithValues:) changes only to Embedded Swift 2025-01-28 16:22:46 -08:00
Alejandro Alonso
d2309d264d Fix tests 2025-01-28 12:50:51 -08:00
Kuba (Brecka) Mracek
53921e4c8c Merge pull request #78920 from kubamracek/embedded-wae
[embedded] Support withoutActuallyEscaping in Embedded Swift
2025-01-28 12:32:48 -08:00
Saleem Abdulrasool
f1b859c9a5 Concurrency: centralise the definition for std::bit_cast
Remove the multiple definitions of `std::bit_cast` into a header. While
this is still not great, it does reduce the duplication. This also
silently works towards reducing a bit of the UB introduced here by
adding an inline namespace for `std` which you are not technically
allowed to use. However, by doing this, we have a clear migration path
away from this once we adopt C++20.
2025-01-28 11:14:15 -08:00
Saleem Abdulrasool
21841fc3a3 Merge pull request #78911 from compnerd/bitcasting
Concurrency: silence some `-Wcast-function-type-mismatch` warnings
2025-01-28 10:53:10 -08:00
Dario Rexin
0587075839 Merge pull request #78890 from drexin/wip-143429827
[Runtime] Add compatibility override support for CVW runtime functions
2025-01-28 10:33:52 -08:00
Gabor Horvath
06e5ead8da [cxx-interop] Support borrowing from self in SwiftifyImport
Support adding safe wrappers for APIs returning std::span depending on
the this object. This also fixes an issue for APIs with 0 parameters.

rdar://139074571
2025-01-28 13:54:10 +00:00
Alastair Houghton
ab8e561583 Merge pull request #78516 from al45tair/eng/PR-124913332
[Backtracing] Implement API per SE-0419
2025-01-28 10:48:33 +00:00
Dario Rexin
e15bdc132c [Runtime] Rename CVW entry points for compatibility 2025-01-27 15:43:01 -08:00
Kuba Mracek
f4c69e1ca0 [embedded] Also allow nil in swift_isEscapingClosureAtFileLocation to match the C++ runtime 2025-01-27 10:20:23 -08:00
Alastair Houghton
26d0e49764 [Backtracing] Updates following review.
Added some explanatory text to the Compact Backtrace Format
documentation, and also to the `CMakeLists.txt` for the runtime.

Tweaked the conversions for `Backtrace.Address` to truncate, which
should result in reasonable behaviour for negative fixed-width
integers.

Use a constant for the ASCII values for `/` and `\` in the Compact
Image Format encoder/decoder.

Make the TSD key for `ElfImageCache` non-optional, and call
`fatalError()` if we don't get one.

rdar://124913332
2025-01-27 17:22:39 +00:00
Alastair Houghton
c9c5dc0de1 [Backtracing] Add platform and architecture information.
It's useful to capture the platform and platform version with the image map.
Also, display both the platform and architecture information when generating
a crash log.

rdar://124913332
2025-01-27 15:44:28 +00:00
Kuba Mracek
8e3ee38324 [embedded] Support withoutActuallyEscaping in Embedded Swift 2025-01-25 15:24:20 -08:00
Kuba Mracek
c99e9e4922 [embedded] Support Dictionary.init(uniqueKeysWithValues:) in Embedded Swift 2025-01-25 14:55:19 -08:00
Saleem Abdulrasool
c9df7c57a9 Concurrency: silence some -Wcast-function-type-mismatch warnings
The C++ standard does not guarantee that the code and data pointers are
interchangeable. Recent enhancements to clang now properly identify the
improper `reinterpret_cast` between function types. Silence the warning
by switching to `std::bit_cast`. Unfortunately, this is a C++20 feature
and we are still on C++17. In the case that the compiler doesn't have a
`bit_cast` implementation, fallback with some UB to a local definition.
2025-01-25 10:37:01 -08:00
Saleem Abdulrasool
0dc31a8469 Merge pull request #78900 from compnerd/typechecked
runtime: restore some typechecking for keypath functions
2025-01-25 08:07:41 -08:00
Tim Kientzle
674c76274e Merge pull request #77062 from tbkka/tbkka-remotemirror-133890406
Let indirect enum cases export spare bits
2025-01-24 19:52:59 -08:00
Saleem Abdulrasool
70b7c5446b runtime: restore some typechecking for keypath functions
This addresses some feedback on #78141 as per @rjmccall. Ensure that the
runtime functions match the expected signature.
2025-01-24 16:52:28 -08:00
Dario Rexin
92bebee121 [Runtime] Add compatibility override support for CVW runtime functions
rdar://143429827
2025-01-24 15:11:52 -08:00