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

fix(bootstrap): deserialize null as f64::NAN #136034

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

weihanglo
Copy link
Member

When doing optimized build through opt-dist,
I've often run into errors like invalid type: null, expected f64.
This is likely because some f64 fields might actually bet set null.
Unfortunately, serde_json doesn't handle null <-> NaN well.

This commit addresses it by having a custom deserialize method, so null is always be deserialized to f64:NAN.

See:

r? @Kobzol

When doing optimized build through opt-dist,
I've often run into errors like `invalid type: null, expected f64`.
This is likely because some f64 fields might actually bet set null.
Unfortunately, serde_json doesn't handle null <-> NaN well.

This commit addresses it by having a custom deserialize method, so
null is always be deserialized to `f64:NAN`.

See:

* https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/opt-dist.3A.20.60invalid.20type.3A.20null.2C.20expect.20f64.60.20failure
* serde-rs/json#202
@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 2025

Could not assign reviewer from: Kobzol.
User(s) Kobzol are either the PR author, already assigned, or on vacation. Please use r? to specify someone else to assign.

@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 25, 2025
@workingjubilee
Copy link
Member

I thought JSON was supposed to support NaN literals?

@workingjubilee
Copy link
Member

huh, won't go into my browser's JSON.parse. Guess not.

@workingjubilee
Copy link
Member

inf isn't supported either. wild.

@compiler-errors
Copy link
Member

It's so incredibly funny that serde_json can't roundtrip NaN. From the linked issue this definitely looks like the ""right"" way to fix this for now.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 25, 2025

📌 Commit 5f8bcec has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2025
@jieyouxu
Copy link
Member

serde_json is probably following the Proper JSON spec which accepts "numbers", i.e.

Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2025
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#135971 (Properly report error when object type param default references self)
 - rust-lang#135977 (Fix `FormattingOptions` instantiation with `Default`)
 - rust-lang#135985 (Rename test to `unresolvable-upvar-issue-87987.rs` and add some notes)
 - rust-lang#135991 (Fix set_name in thread mod for NuttX)
 - rust-lang#136009 (bootstrap: Handle bootstrap lockfile race condition better)
 - rust-lang#136018 (Use short ty string for move errors)
 - rust-lang#136027 (Skip suggestions in `derive`d code)
 - rust-lang#136029 (Bootstrap: Don't move ownership of job object)
 - rust-lang#136034 (fix(bootstrap): deserialize null as `f64::NAN`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a330c7e into rust-lang:master Jan 25, 2025
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2025
Rollup merge of rust-lang#136034 - weihanglo:null-as-f64-nan, r=compiler-errors

fix(bootstrap): deserialize null as `f64::NAN`

When doing optimized build through opt-dist,
I've often run into errors like `invalid type: null, expected f64`.
This is likely because some f64 fields might actually bet set null.
Unfortunately, serde_json doesn't handle null <-> NaN well.

This commit addresses it by having a custom deserialize method, so null is always be deserialized to `f64:NAN`.

See:

* https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/opt-dist.3A.20.60invalid.20type.3A.20null.2C.20expect.20f64.60.20failure
* serde-rs/json#202

r? `@Kobzol`
@rustbot rustbot added this to the 1.86.0 milestone Jan 25, 2025
@weihanglo weihanglo deleted the null-as-f64-nan branch January 25, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants