Skip to content

[SR-5438] Something is up with do/try/catch on the port to Android #48012

Closed
@johnno1962

Description

@johnno1962
Previous ID SR-5438
Radar None
Original Reporter @johnno1962
Type Bug
Status Closed
Resolution Done
Environment

http://johnholdsworth.com/android_toolchain.tgz

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

md5: 811dce9ad8c11216c611c20e8ee4b825

relates to:

  • SR-5414 ImageInspectionELF.cpp:getSectionInfo crashes on Android

Issue Description:

I’ve been chipping away at getting Swift to work on Android and found that there are problems with the implementation of do/try/catch when swift is run an Android device.

The following example program:

import Foundation

print("Hello, Android")

do {
      print("HERE1")
      try { throw NSError(domain:"Oh", code:-1) }()
}
catch let err as Error {
      print("HERE2")
}

print("DONE")

Produces this output on Linux/macOS:

Hello, Android
HERE1
HERE2
DONE

Whereas on Android following the instructions from https://github.com/apple/swift/blob/master/docs/Android.md

produces the following output:

Hello, Android
HERE1
DONE

This is causing crashes in corefoundation where errors should have been trapped and code goes down the wrong path as a result. This is from a version of Swift from master about a month ago. I’ll be building from a more up to date version soon and will close this report if this is resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidPlatform: AndroidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfruntimeThe Swift Runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions