Commit Graph

61 Commits

Author SHA1 Message Date
Arnold Schwaighofer
e106161d8f Speculative fix for linux bot linker failure 2018-03-09 17:55:39 -08:00
Mike Ash
406ebaddfc [Runtime] Implement overflow check for weak refcounts (#14023)
* Check for overflow in incrementWeak().

This mirrors what is currently done for unowned reference counts, where overflowing the side table field produces a fatal error. Without this, the count silently wrapped from 2^31-1 to 0, which then caused breakage when the balancing releases happened (possibly including use-after-free bugs).

* Fix the implementation of RefCounts::getWeakCount().

The previous implementation was only appropriate for heap objects, but not side tables. This resulted in the weak count always returning 0 or 1. This change specializes the implementation for the two different cases and returns the correct count for side tables.

* Test large weak retain counts.

This tests the largest allowed weak retain count, as well as the overflow check when that count is exceeded.
2018-01-19 19:13:47 -08:00
Saleem Abdulrasool
d7fc6a0359 stdlib: initialize va_list variables (NFC)
This silences `-Wuninitialized` warnings from clang when building the
swift stdlib for Windows ARM.  NFC.
2017-10-06 15:33:43 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Saleem Abdulrasool
8bf538cab1 Merge pull request #11947 from compnerd/windows-demangling
runtime: add undecoration support for Windows
2017-09-18 14:50:33 -07:00
Saleem Abdulrasool
a22fc82535 runtime: clean up -Wformat warning
Add explicit casts to convert the `void *` to an integral value to
convert via printf.  NFC.
2017-09-15 17:52:37 -07:00
Saleem Abdulrasool
fb68207f0c runtime: add undecoration support for Windows
Use the Windows API `UnDecorateSymbolName` rather than `__cxa_demangle`
to undecorate the C++ symbols.  `__cxa_demangle` is only available in
the itanium ABI, not under MS ABI.  This allows us to properly
undecorate symbols on Windows.
2017-09-15 17:48:43 -07:00
Saleem Abdulrasool
d0a6131b53 runtime: clean up -Wunused-function warning
This function is only used when backtracing is enabled.  Use a
preprocessor guard to avoid defining the function when not used.  This
prevents a -Wunused-function warning.  NFC.
2017-09-15 10:12:34 -07:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Arnold Schwaighofer
d8abd2fed9 runtime: Fix overflow of swift_unownedRetain reference counts
On 32bit platforms there are 7 bits reserved for the unowned retain count. This
makes overflow a likely scenario. Implement overflow into the side table.

rdar://33495003
2017-08-02 07:12:47 -07:00
Jordan Rose
9c10398514 [runtime] Expose reportToDebugger as swift_reportToDebugger.
...so that the overlays can use it. See next commit.
2017-07-13 11:18:41 -07:00
Kuba (Brecka) Mracek
150696f8f6 On Linux, make swift_reportError always print backtraces (#10638)
On Linux, make swift_reportError always print backtraces.
2017-06-27 21:53:55 -07:00
Kuba (Brecka) Mracek
d29557bd24 Change the signature of reportToDebugger and _swift_runtime_on_report to avoid using 'bool'. It's much easier to work with native-width integers only in LLDB. (#10523) 2017-06-22 21:22:27 -07:00
Kuba (Brecka) Mracek
dc3e6c1116 Prevent _swift_runtime_on_report from having its arguments optimized out. Turns out an empty "asm volatile" isn't enough and we need to explicitly ask that the arguments are also not optimized out. (#10456) 2017-06-21 16:54:54 -07:00
Kuba (Brecka) Mracek
fec8d72ea3 Debugger hook/breakpoint for issue reporting from the Swift runtime (#10293)
* Implements a debugger hook (breakpoint) API and data structure. This structure is passed to the debugger and describes extra information about a fatal error or a non-fatal warning, which should be logged as a runtime issue.

This debugger hook is then used from two places, which currently only log to stderr:
- Runtime exclusivity violations.
- Swift 3 implicit Obj-C entrypoints.

A subsequent LLDB support will be able to catch these callbacks and show the runtime issues in a better way than just logging them to stderr.  When the debugger is not attached, this shouldn't have any effect.
2017-06-19 14:28:19 -07:00
John Holdsworth
d600e7581d Use #elif 2017-05-30 20:16:40 +01:00
John Holdsworth
e45ddc8955 Ensure fatalError message logged on Android 2017-05-23 01:47:07 +01:00
Kuba (Brecka) Mracek
a5a59f5aed [runtime] Enhance output from dynamic exclusivity violations. Print current stacktrace and the symbolicated frame of the previous conflicting access. (#9501) 2017-05-12 20:28:28 -07:00
Kuba (Brecka) Mracek
fc7dbefcf8 Revert backtrace ban and start printing backtraces from the runtime again (#9528)
* Revert "[strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled."
This reverts commit 6bc28ff1c9.
* Bring back important fixes from the revert of 6bc28ff1c9.
* Change swift::swift_reportError to only print the backtrace in assert builds (swift::warning prints backtrace always).
2017-05-12 15:46:35 -07:00
Michael Gottesman
6bc28ff1c9 [strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled.
This commit disables runtime stack trace dumping via dladdr on Darwin when
asserts are disabled.

This stack trace dumping was added as a way to improve the ability to debug the
compiler for compiler developers. This is all well and good but having such a
feature always enabled prevents us from reducing the size of the swift standard
library by eliminating the swift nlist.

rdar://31372220
2017-05-04 16:46:26 -06:00
Doug Gregor
cd811edb14 [Runtime] Add a “swift::warning” entrypoint for runtime warnings.
Like swift::fatalError(), but without the abort or crash logging.
2017-03-31 21:22:16 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00
Greg Parker
ae1c984920 New refcount representation (#5282)
New refcount representation and weak variable implementation. See SwiftShims/RefCount.h for details.
2017-02-24 14:19:11 -08:00
Hugh Bellamy
63cf2d561e Remove extern "C" from uses of SWIFT_RUNTIME_EXPORT 2017-01-22 18:32:17 +00:00
Hugh Bellamy
4e55214c18 Remove CRASH_REPORTER_CLIENT_HIDDEN in favour of equivilent LLVM macro 2017-01-20 13:48:56 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
61c83ab5eb Change _MSC_VER conditions to _WIN32 in runtime 2016-12-19 15:54:49 +00:00
practicalswift
76f0fdd670 [gardening] NULL → nullptr 2016-12-09 23:17:54 +01:00
Simon Evans
c17ca759aa [runtime] Add platform independent version of dladdr() / Dl_info
- Win32 does not support dlfcn.h, Dl_info or dladdr() so add
  lookupSymbol() as a wrapper for ELF/MachO/Win32

- Win32 version needs an implementation, currently it just returns
  an error for `cannot lookup address'
2016-11-29 00:05:11 +00:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
John Holdsworth
a430c40303 Bug in Windows swift_vasprintf() 2016-09-23 06:50:22 +01:00
Grzegorz Miłoś
201c19dc98 Review comments, round 3. 2016-09-07 12:14:48 +01:00
Grzegorz Miłoś
dc3369dffe Review comments. Mostly python improvements in symbolicate-linux-fatal(.py). 2016-09-07 12:14:48 +01:00
Grzegorz Miłoś
f068b1eb33 [SR-755] Tool for re-symbolicating fatal stacktraces on Linux. 2016-09-07 12:14:48 +01:00
Han Sangjin
e6ecc9a3ec Modified for some reviews 2016-06-10 06:26:47 +09:00
Han Sangjin
198441bee9 stdlib/msvc: Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build.
2016-06-04 05:16:41 +09:00
Dmitri Gribenko
8ac074687d runtime: remove unused includes 2016-05-30 19:36:26 -07:00
Michael Gottesman
8308ad85e2 Merge pull request #2485 from gottesmm/change-backtrace-to-use-dladdr-directly-instead-of-backtrace_symbol
When producing backtraces, do not use backtrace_symbol, invoke dladdr…
2016-05-11 17:28:36 -07:00
Michael Gottesman
7523d1a60b When producing backtraces, do not use backtrace_symbol, invoke dladdr directly.
Previously, we were using backtrace_symbol and then parsing/modifying its
output. By just using dladdr directly, we have a cleaner and more robust
solution.

rdar://25064742
2016-05-11 15:40:10 -07:00
Saleem Abdulrasool
81661fca61 stdlib: use the reserved attribute spellings
This is a purely mechanical change replacing the attributes with the reserved
spelling.  Compilers are to not error when they encounter a reserved spelling
for an attribute which they do not support.
2016-05-11 11:30:24 -07:00
Jacob Mizraji
f8a79282f2 Resolve ambiguity in mutex declaration 2016-05-05 12:01:23 -07:00
Jacob Mizraji
880026194e Changed StaticUnsafeMutex to have the swift:: namespace
to fix upstream clang build errors.
2016-05-02 18:14:21 -07:00
Shawn Erickson
d78c6e3403 [runtime] addressed review comments outlined in #1950 2016-04-28 10:39:35 -07:00
Greg Parker
590d41c00a [runtime] enhanced and refactored recently added Mutex abstraction (Merge pull request #1950 from shawnce/SR-946_rw)
[runtime] enhanced and refactored recently added Mutex abstraction
2016-04-26 16:18:12 -07:00
Zhuowei Zhang
7c502b6344 Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`
invocation:

```
$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
2016-04-12 19:26:21 -04:00
Shawn Erickson
a0452be947 [runtime] enhanced and refactored recently added Mutex abstraction
- added read / write lock support
- added non-fatal error support to allow use of mutex in fatal error reporting pathway
- isolated pthread implementation to it own header/cpp file pair
- expanded unit tests to cover new code as well as better test existing mutex
- removed a layer of complexity that added no real value
2016-04-06 13:02:37 -07:00
Shawn Erickson
3292124f87 [runtime] - switched most runtime code to use swift::Mutex and swift::Condition (see SR-946) 2016-03-20 22:56:48 -07:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
Harlan Haskins
7bd071ca6c [runtime] Fix leak in backtrace demangling 2016-02-02 15:44:34 -08:00