xamarin-macios/runtime
Rolf Bjarne Kvinge 350f597250
[runtime] Fix memory leak with BlockLiteral descriptors. Fixes #20503. (#20556)
We're using two different functions to atomically decrement a reference count,
the native `atomic_fetch_sub` and the managed `Interlocked.Decrement`.

Unfortunately the return value is not the same: `atomic_fetch_sub` returns the
original value before the subtraction, while `Interlocked.Decrement` returns
the subtracted value, while our code assumed the functions behaved the same.
This resulted in a memory leak, because we'd incorrectly expect `0` to be
returned from `atomic_fetch_sub` when the reference count reaches zero, and
thus not detect when the descriptor a block should be freed.

The fix is to update the expected return value from `atomic_fetch_sub` to be
`1` instead of `0`.

Fixes https://github.com/xamarin/xamarin-macios/issues/20503.
2024-05-06 09:05:58 +02:00
..
xamarin [runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415) 2023-11-14 07:42:55 +01:00
.gitignore [runtime] Validate that the static registrar code being registered was built using the same runtime. (#16652) 2022-11-10 10:45:20 +01:00
COOP.md
Delegates.cs.t4 [runtime] Don't register Runtime.GetGenericMethodFromToken when the managed static registrar is used. (#20144) 2024-02-20 16:47:13 +01:00
EXCEPTIONS.md
Makefile [runtime] Fix min OS versions in various compiler and linker arguments. (#20275) 2024-03-08 07:26:41 +01:00
README.md
Xamarin.framework-iphoneos.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
Xamarin.framework-iphonesimulator.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
Xamarin.framework-tvos.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
Xamarin.framework-tvsimulator.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
Xamarin.framework-watchos.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
Xamarin.framework-watchsimulator.Info.plist [net8.0-xcode15] [runtime] Bump the min OS version in the Info.plist in Xamarin.framework. (#18912) 2023-09-05 10:26:44 +02:00
bindings-generator.cs Change all null checking expressions to use 'is' and 'is not'. (#18176) 2023-05-05 17:52:19 +02:00
bindings-generator.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
bindings.h [UIKit] Wrap the call to UIApplicationMain in a @try/@catch handler. (#15746) 2022-08-26 13:56:33 +02:00
bindings.m [UIKit] Wrap the call to UIApplicationMain in a @try/@catch handler. (#15746) 2022-08-26 13:56:33 +02:00
coreclr-bridge.m Exclude assemblies from NativeAOT app bundles (#18532) 2023-07-06 12:52:28 -04:00
delegates.h.t4
delegates.inc.t4 [runtime] Implement functions for getting and setting array elements for CoreCLR. (#11519) 2021-05-13 07:11:49 +02:00
delegates.t4 [runtime] Don't register Runtime.CreateDelegateProxy when using the managed static registrar. (#20164) 2024-02-22 08:51:34 +01:00
exports.t4 [runtime] Remove native usage of MonoReferenceQueue and use a ConditionalWeakTable in managed code instead. (#17429) 2023-02-06 07:57:51 +01:00
extension-main.m
frameworks.h [runtime] MapKit is available on macOS/arm64. (#11363) 2021-04-29 14:45:58 +02:00
launcher.h
launcher.m [runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415) 2023-11-14 07:42:55 +01:00
libmonotouch.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
libxammac.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
main-internal.h
mono-runtime.h.t4 [tools] Use MONO_AOT_MODE_INTERP_ONLY instead of MONO_AOT_MODE_INTERP for x86_64. (#15429) 2022-07-12 09:56:51 +02:00
mono-runtime.m.t4 [runtime] Deal with the rest of the Mono Embedding API for CoreCLR. (#11642) 2021-05-21 07:53:41 +02:00
monotouch-debug.h [runtime] Move a few mono function declaration to the generated logic for mono function declarations instead of doing it manually. (#10849) 2021-03-12 07:37:27 +01:00
monotouch-debug.m [runtime] Add support for passing on a connect timeout to sdb. (#18037) 2023-04-13 16:34:52 +02:00
monotouch-main.m Exclude assemblies from NativeAOT app bundles (#18532) 2023-07-06 12:52:28 -04:00
monotouch-support.h
monovm-bridge.m [runtime] Use the built-in support in MonoVM for autorelease pools on threadpool threads. Fixes #11788. (#16751) 2022-11-15 17:44:41 +01:00
nativeaot-bridge.m [runtime] Create a version of our runtime that can be used with NativeAOT. 2023-06-21 20:49:49 +02:00
nsstring-localization.m
product.in.h [runtime] Validate that the static registrar code being registered was built using the same runtime. (#16652) 2022-11-10 10:45:20 +01:00
runtime-generated.h.t4 [runtime] Add support for generating managed delegates only for CoreCLR. 2021-03-25 07:32:32 +01:00
runtime-internal.h [runtime] Add support for tracking created and destroyed MonoObject* instances for CoreCLR. (#11657) 2021-05-25 08:19:27 +02:00
runtime.m [runtime] Fix conserving stack trace when re-throwing marshalled exceptions. Fixes #19417. (#20316) 2024-03-18 15:02:12 +01:00
shared.h [runtime] Move the code to wrap every managed thread with an NSAutoreleasePool to the MonoVM bridge. (#11257) 2021-04-21 16:21:09 +02:00
shared.m [runtime] Fix memory leak with BlockLiteral descriptors. Fixes #20503. (#20556) 2024-05-06 09:05:58 +02:00
slinked-list.h
trampolines-arm64-asm.s [runtime] Add correct prologue/epilogue to xamarin_arm64_common_trampoline 2021-05-11 15:54:39 +02:00
trampolines-arm64-objc_msgSend.inc.s [runtime] Be a bit defensive after handling Objective-C exceptions and return a consistent value. (#11601) 2021-05-19 07:35:46 +02:00
trampolines-arm64-objc_msgSend.s [runtime] Implement xamarin_dyn_objc_msgSend for ARM64. 2021-05-11 15:54:39 +02:00
trampolines-arm64-objc_msgSendSuper.s [runtime] Implement xamarin_dyn_objc_msgSend for ARM64. 2021-05-11 15:54:39 +02:00
trampolines-arm64.h Xamarin.Mac native Apple Silicon targetting support (#10115) 2021-03-17 21:48:02 -04:00
trampolines-arm64.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-i386-asm.s
trampolines-i386-objc_msgSend-copyframe.inc
trampolines-i386-objc_msgSend-post.inc
trampolines-i386-objc_msgSend-pre.inc
trampolines-i386-objc_msgSend.s
trampolines-i386-objc_msgSendSuper.s
trampolines-i386-objc_msgSendSuper_stret.s
trampolines-i386-objc_msgSend_stret.s
trampolines-i386.h
trampolines-i386.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-internal.h Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-invoke.m [Xcode 13.3] Initial commit to Xcode 13.3 release 2022-03-14 22:54:33 -04:00
trampolines-varargs.h
trampolines-varargs.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-x86_64-asm.s
trampolines-x86_64-objc_msgSend-copyframe.inc
trampolines-x86_64-objc_msgSend-post.inc
trampolines-x86_64-objc_msgSend-pre.inc
trampolines-x86_64-objc_msgSend.s
trampolines-x86_64-objc_msgSendSuper.s
trampolines-x86_64-objc_msgSendSuper_stret.s
trampolines-x86_64-objc_msgSend_stret.s
trampolines-x86_64.h
trampolines-x86_64.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines.m [runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415) 2023-11-14 07:42:55 +01:00
xamarin-support.m [runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415) 2023-11-14 07:42:55 +01:00

README.md

Native runtime

This directory contains the native runtime for Xamarin.iOS and Xamarin.Mac.

Cooperative GC

See COOP.md

Generated code

A few files are generated automatically:

delegates.h|inc, Delegates.cs

These files contain the code required to glue the native runtime and the managed runtime.

mono-runtime.m, xamarin/mono-runtime.h

These files contain code that makes other code, consumers of the mono runtime, oblivious to whether the mono runtime is linked statically, dynamically, or using dlopen at runtime.

If you need to use a new function from the Mono headers, add it to exports.t4.

If you need a new enum / constant / typedef / etc, add it to mono-runtime.h.t4.

Shipped headers

These are the headers shipped with XI/XM (they're not for public consumption, but we need them to build generated code on customers machine, in particular main.m and registrar.m)

xamarin/runtime.h xamarin/trampolines.h xamarin/main.h xamarin/xamarin.h