Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8249] Crash when accessing JSONDecoder userInfo dictionary #50781

Open
swift-ci opened this issue Jul 13, 2018 · 2 comments
Open

[SR-8249] Crash when accessing JSONDecoder userInfo dictionary #50781

swift-ci opened this issue Jul 13, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8249
Radar rdar://problem/42168089
Original Reporter dalu93 (JIRA User)
Type Bug

Attachment: Download

Environment

iOS 11.3.0, iPhone 5S

Xcode 9.4.1 (9F2000)

MacOS High Sierra 10.13.5

Happening only in Release build, not in debug mode

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, OptimizedOnly, RunTimeCrash
Assignee None
Priority Medium

md5: d9ee99b5827849c27fe10ac0d59e741c

Issue Description:

Hi,

I'm experiencing a crash happening when using the userInfo dictionary in the `JSONDecoder` object.

The code which is crashing is the following:

extension JSONDecoder {

    func decode<T>(
        _ type: T.Type,
        from data: Data,
        keyPath: String? = nil,
        keyPathSeparator separator: String = "."
    ) throws -> T where T: Decodable {
        if let keyPath = keyPath {
            userInfo[keyPathUserInfoKey] = keyPath.components(separatedBy: separator)
            return try decode(KeyPathWrapper<T>.self, from: data).object
        }

        return try decode(T.self, from: data)
    }

}

The crash is the following:

APP_NAME(7636,0x16f14f000) malloc: *** error for object 0x10ffd4d60: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

And the stack trace for this thread is the following

- 0 : "0   ???                                 0x000000010f114890 0x0 + 4547758224"
  - 1 : "1   ???                                 0x000000010f114964 0x0 + 4547758436"
  - 2 : "2   APP_NAME                       0x0000000100d464c8 main + 0"
  - 3 : "3   libsystem_c.dylib                   0x0000000182693d0c abort + 140"
  - 4 : "4   libsystem_malloc.dylib              0x000000018275d838 <redacted> + 0"
  - 5 : "5   libswiftCore.dylib                  0x0000000106ba8f00 _swift_release_dealloc + 28"
  - 6 : "6   APP_NAME                       0x0000000100d60a0c _T0ypSgWh0_ + 28"
  - 7 : "7   APP_NAME                       0x0000000100d658b4 _T09Alamofire11DataRequestC9ApproveItE27decodableResponseSerializerAA0bgH0VyxG10Foundation11JSONDecoderC7decoder_SSSg7keyPathts9DecodableRzlFZAA6ResultOyxGAI10URLRequestVSg_So15HTTPURLResponseCSgAI0B0VSgs5Error_pSgtcfU_ + 332"
  - 8 : "8   APP_NAME                       0x0000000100d65a00 _T09Alamofire11DataRequestC9ApproveItE27decodableResponseSerializerAA0bgH0VyxG10Foundation11JSONDecoderC7decoder_SSSg7keyPathts9DecodableRzlFZAA6ResultOyxGAI10URLRequestVSg_So15HTTPURLResponseCSgAI0B0VSgs5Error_pSgtcfU_TA + 44"
  - 9 : "9   Alamofire                           0x0000000104c8e7a0 _T09Alamofire11DataRequestC8responseACXDSo13DispatchQueueCSg5queue_x0D10SerializeryAA0B8ResponseVy16SerializedObjectQzGc17completionHandlertAA0biH8ProtocolRzlFyycfU_ + 1460"
  - 10 : "10  Alamofire                           0x0000000104c8b8f0 _T0Ieg_IeyB_TR + 36"
  - 11 : "11  Foundation                          0x00000001836c6e88 <redacted> + 16"
  - 12 : "12  Foundation                          0x00000001836088d0 <redacted> + 72"
  - 13 : "13  Foundation                          0x0000000183607cac <redacted> + 848"
  - 14 : "14  libdispatch.dylib                   0x00000001072e9220 _dispatch_client_callout + 16"
  - 15 : "15  libdispatch.dylib                   0x00000001072f5850 _dispatch_block_invoke_direct + 232"
  - 16 : "16  libdispatch.dylib                   0x00000001072e9220 _dispatch_client_callout + 16"
  - 17 : "17  libdispatch.dylib                   0x00000001072f5850 _dispatch_block_invoke_direct + 232"
  - 18 : "18  libdispatch.dylib                   0x00000001072f5734 dispatch_block_perform + 104"
  - 19 : "19  Foundation                          0x00000001836c8750 <redacted> + 376"
  - 20 : "20  libdispatch.dylib                   0x00000001072e9220 _dispatch_client_callout + 16"
  - 21 : "21  libdispatch.dylib                   0x00000001072f64d8 _dispatch_continuation_pop + 588"
  - 22 : "22  libdispatch.dylib                   0x00000001072f4dc8 _dispatch_async_redirect_invoke + 628"
  - 23 : "23  libdispatch.dylib                   0x00000001072fa84c _dispatch_root_queue_drain + 604"
  - 24 : "24  libdispatch.dylib                   0x00000001072fa584 _dispatch_worker_thread3 + 136"
  - 25 : "25  libsystem_pthread.dylib             0x00000001828c3fac _pthread_wqthread + 1176"
  - 26 : "26  libsystem_pthread.dylib             0x00000001828c3b08 start_wqthread + 4"

In attachment the debugger tab

@belkadan
Copy link
Contributor

This sounds familiar but I'm not sure whether we've fixed it. We might need a project to reproduce, though.

@swift-ci create

@bob-wilson
Copy link

I don't know how to tell if it has been fixed if we don't know how to reproduce it. Luca, can you provide a sample project that we can build and run to observe this problem ourselves?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

4 participants