Skip to content

Runtime crash 'freed pointer was not the last allocation' in Xcode 26 when using withCheckedThrowingContinuation #84793

@TimofeiKarpovR

Description

@TimofeiKarpovR

Description

After updating from Xcode 16.4 to Xcode 26.0.1 our apps started crashing when running Debug configuration on withCheckedThrowingContinuation calls with SIGABRT and the message:

freed pointer was not the last allocation

The issue affects only withCheckedThrowingContinuation - withUnsafeThrowingContinuation and withCheckedContinuation do not crash.

Reproduction

Simple new iOS project with default settings, except:

  • Disable Default actor isolation to Main Actor
  • Set iOS Deployment Target to a version lower than iOS 18.0 (related to @backDeployed?).

Certain static frameworks are required - see the sample project for the exact list.

import UIKit
import GRPC

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Need to call something from GRPC
        _ = GRPCStatus(code: .cancelled)

        // Crash is here:
        Task {
            try await withCheckedThrowingContinuation { continuation in
                continuation.resume()
            }
        }
        
        return true
    }

   ...
}

Sample project: ContinuationCrashSample

Stack dump

* thread #9, name = 'Task 1', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001008dc874 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001014962a8 libsystem_pthread.dylib`pthread_kill + 264
    frame #2: 0x00000001801ad950 libsystem_c.dylib`abort + 100
  * frame #3: 0x00000002584de7d4 libswift_Concurrency.dylib`swift::swift_Concurrency_fatalErrorv(unsigned int, char const*, char*) + 28
    frame #4: 0x00000002584de7f0 libswift_Concurrency.dylib`swift::swift_Concurrency_fatalError(unsigned int, char const*, ...) + 28
    frame #5: 0x00000002584e25e4 libswift_Concurrency.dylib`swift_task_dealloc + 128
    frame #6: 0x0000000101fa191c ContinuationCrashSample.debug.dylib`closure #1() at AppDelegate.swift:20:23
  thread #2, queue = 'TPC issue queue'
    frame #0: 0x00000001008d682c libsystem_kernel.dylib`__ulock_wake + 8
    frame #1: 0x0000000100c814d4 libsystem_platform.dylib`_os_unfair_lock_unlock_slow + 52
    frame #2: 0x0000000100a8eb14 dyld_sim`dyld4::APIs::findImageMappedAt(void const*, dyld3::MachOLoaded const**, bool*, char const**, void const**, unsigned long long*, unsigned char*, dyld4::Loader const**) + 528
    frame #3: 0x0000000100a8edd8 dyld_sim`dyld4::APIs::dyld_image_path_containing_address(void const*) + 68
    frame #4: 0x00000001800df050 libsystem_trace.dylib`_os_activity_stream_reflect + 336
    frame #5: 0x00000001800dee88 libsystem_trace.dylib`_os_activity_create_addr + 1460
    frame #6: 0x00000001800ef228 libsystem_trace.dylib`_os_log_impl_flatten_and_send + 8268
    frame #7: 0x00000001800ed1c4 libsystem_trace.dylib`_os_log + 164
    frame #8: 0x00000001800f40d8 libsystem_trace.dylib`_os_log_fault_impl + 20
    frame #9: 0x0000000100dc69f8 libRPAC.dylib`culledOsLogFault + 1240
    frame #10: 0x0000000100dc7ec8 libRPAC.dylib`__generateCulledBacktrace_block_invoke_2 + 4652
    frame #11: 0x0000000101403f04 libdispatch.dylib`_dispatch_block_async_invoke2 + 104
    frame #12: 0x000000010140d9dc libdispatch.dylib`_dispatch_client_callout + 12
    frame #13: 0x00000001013fe080 libdispatch.dylib`_dispatch_workloop_invoke + 1328
    frame #14: 0x0000000101409294 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 324
    frame #15: 0x00000001014087f0 libdispatch.dylib`_dispatch_workloop_worker_thread + 752
    frame #16: 0x0000000101492b88 libsystem_pthread.dylib`_pthread_wqthread + 288
  thread #3, queue = 'com.apple.libtrace.state.block-list'
    frame #0: 0x00000001008d6770 libsystem_kernel.dylib`__ulock_wait + 8
    frame #1: 0x00000001013f5f10 libdispatch.dylib`_dlock_wait + 52
    frame #2: 0x00000001013f5d1c libdispatch.dylib`_dispatch_thread_event_wait_slow + 52
    frame #3: 0x0000000101404930 libdispatch.dylib`__DISPATCH_WAIT_FOR_QUEUE__ + 408
    frame #4: 0x00000001014042a4 libdispatch.dylib`_dispatch_sync_f_slow + 192
    frame #5: 0x00000001800f2fa4 libsystem_trace.dylib`___os_state_request_for_self_block_invoke + 340
    frame #6: 0x00000001013f3fb8 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #7: 0x000000010140d9dc libdispatch.dylib`_dispatch_client_callout + 12
    frame #8: 0x00000001013fc494 libdispatch.dylib`_dispatch_lane_serial_drain + 888
    frame #9: 0x00000001013fd0f8 libdispatch.dylib`_dispatch_lane_invoke + 428
    frame #10: 0x0000000101409294 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 324
    frame #11: 0x00000001014087f0 libdispatch.dylib`_dispatch_workloop_worker_thread + 752
    frame #12: 0x0000000101492b88 libsystem_pthread.dylib`_pthread_wqthread + 288
  thread #4, stop reason = thread-creation
    frame #0: 0x0000000101491984 libsystem_pthread.dylib`start_wqthread
  thread #5, stop reason = thread-creation
    frame #0: 0x0000000101491984 libsystem_pthread.dylib`start_wqthread
  thread #6, stop reason = thread-creation
    frame #0: 0x0000000101491984 libsystem_pthread.dylib`start_wqthread
  thread #7, name = 'com.apple.uikit.eventfetch-thread'
    frame #0: 0x00000001008d4b70 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000001008e5fac libsystem_kernel.dylib`mach_msg2_internal + 72
    frame #2: 0x00000001008dcc28 libsystem_kernel.dylib`mach_msg_overwrite + 480
    frame #3: 0x00000001008d4ed8 libsystem_kernel.dylib`mach_msg + 20
    frame #4: 0x000000018044cd3c CoreFoundation`__CFRunLoopServiceMachPort + 156
    frame #5: 0x000000018044bef4 CoreFoundation`__CFRunLoopRun + 1128
    frame #6: 0x0000000180446e24 CoreFoundation`_CFRunLoopRunSpecificWithOptions + 496
    frame #7: 0x00000001810f1cac Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208
    frame #8: 0x00000001810f1ecc Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 60
    frame #9: 0x00000001863170f8 UIKitCore`-[UIEventFetcher threadMain] + 392
    frame #10: 0x0000000181118b78 Foundation`__NSThread__start__ + 716
    frame #11: 0x00000001014965ac libsystem_pthread.dylib`_pthread_start + 104
  thread #8, stop reason = thread-creation
    frame #0: 0x0000000101491984 libsystem_pthread.dylib`start_wqthread

Expected behavior

It should not crash

Environment

Xcode: 26.0.1
iOS Simulator: iPhone 17 Pro, iOS 26.0
swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions