-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
release builds using rustc 1.86.0 on macOS Ventura (intel) SDK exhibit incorrect behaviour #140686
Copy link
Copy link
Closed
Labels
A-crossArea: Cross compilationArea: Cross compilationA-linkersArea: linkers... you gotta love linkersArea: linkers... you gotta love linkersC-external-bugCategory: issue that is caused by bugs in software beyond our controlCategory: issue that is caused by bugs in software beyond our controlO-appleOperating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Milestone
Metadata
Metadata
Assignees
Labels
A-crossArea: Cross compilationArea: Cross compilationA-linkersArea: linkers... you gotta love linkersArea: linkers... you gotta love linkersC-external-bugCategory: issue that is caused by bugs in software beyond our controlCategory: issue that is caused by bugs in software beyond our controlO-appleOperating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Type
Fields
Give feedbackNo fields configured for issues without a type.
I’d like to report what appears to be a bug in the rust compiler which can be reproduced by using the reqwest crate, where it fails to include the http version string in the request and it only affects binaries that were:
The bug itself has nothing to do with the reqwest crate (looking at the code, it appears that this behaviour should be impossible) and specifically related to the built binary.
this bug does exist in release binaries cross-compiled from linux to macOS when using the macOS 13 (Ventura) SDK with osxcross.
the bug does not exist when creating a debug build or when cross-compiling from an AppleSilicon machine → intel and does not exist when performing a release build on intel → intel when the OS is not Ventura.
We tracked this down to being triggered by
opt-level = 2this bug does not exist in rustc 1.85.0 and appears to only affect 1.86.0 (and also occurs in nightly rust).
I have a reduction:
add reqwest with
--features=blockingand thismain.rs:in another window, start a nc server with:
nc -l localhost 8888then
cargo runand you should see:If you then start a new nc server and
cargo run --releaseyou will see:(note the missing
HTTP/1.1on the first line)when running this code in a debugger, I can see that the slice that’s supposed to add the version number to the request buffer has a length of 0, so it contains no data:
a note from someone on my team who continued to look into it more deeply:
“it looks like it's computing the correct string HTTP/1.1 but for some odd reason it's computing a length of 0. as best I can tell it uses one lookup table of string pointers to find the string, and it uses another lookup table of 4-byte offsets that get added to the lookup table's base address to produce a new pointer, which looks like it's supposed to be the end of the string. Unfortunately that second lookup table has 3 identical values in it, meaning it will produce the correct end pointer for HTTP/1.0 but it produces the start pointer for HTTP/1.1, and so it ends up calculating a length of 0”
This always happens no matter what version of reqwest is used, and it seems to be caused by the rustc version.
I hope this is enough information.