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-14789] Linux - Getting value from property InputStream.streamError traps. #3956

Open
swift-ci opened this issue Jun 17, 2021 · 1 comment
Open

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jun 17, 2021

Previous ID SR-14789
Radar rdar://problem/79456450
Original Reporter GalenRhodes1967 (JIRA User)
Type Bug
Environment
  • Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-74-generic x86_64)
    • Swift version 5.4 (swift-5.4-RELEASE) Target: x86_64-unknown-linux-gnu
  • Ubuntu 20.04.2 LTS (GNU/Linux 5.8.0-55-generic x86_64)
    • Swift version 5.4 (swift-5.4-RELEASE) Target: x86_64-unknown-linux-gnu
  • Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1036-raspi aarch64) - Raspberry PI 4 (4GB)
    • Swift version 5.5-dev (LLVM c64e53b8742ea89, Swift 3f6eb2f8a0a1287) Target: aarch64-unknown-linux-gnu
  • Ubuntu 20.04.2 LTS (GNU/Linux 4.9.241-70 aarch64) - ODROID C4
    • Swift version 5.5-dev (LLVM c64e53b8742ea89, Swift 3f6eb2f8a0a1287) Target: aarch64-unknown-linux-gnu
Additional Detail from JIRA
Votes 0
Component/s Foundation, Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 8041e548b25e485dcc7fa65e64e981dc

Issue Description:

Attempting to read the value of property streamError in InputStream class causes a trap with the error message "Illegal Instruction" on Linux. I've tried this on 4 different Linux machines. Works fine in macOS.

import Foundation
import CoreFoundation

let testDataDir: String = "Tests/RubiconTests/Files"

guard let inputStream = InputStream(fileAtPath: "\(testDataDir)/Test_UTF-8.xml") else {
    print("Unable to create input stream!")
    exit(1)
}
inputStream.open()
if let e = inputStream.streamError { // <----- Crashes here.
    print("File not opened: \(e.localizedDescription)")
    exit(1)
}
var array  = [ UInt8 ](repeating: 0, count: 100)
let result = inputStream.read(&array, maxLength: 100)
guard result >= 0 else {
    let e   = inputStream.streamError // <----- Crashes here.
    let msg = (e?.localizedDescription ?? "Unknown Error")
    print("Error reading file: \(msg)")
    exit(1)
}
let str = String(bytes: array, encoding: .utf8)
print(str ?? "???")
inputStream.close()
exit(0)
@typesanitizer
Copy link

@typesanitizer typesanitizer commented Jun 17, 2021

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants