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

[Merged by Bors] - Make JsString conform to miri tests #2412

Closed
wants to merge 2 commits into from

Conversation

jedel1043
Copy link
Member

This PR rewrites some patterns of the JsString implementation in order to pass all its miri tests. This can be verified by running:

cargo +nightly miri test -p boa_engine string::tests -- --skip builtins --skip parser

Basically, we were doing two operations that were Undefined Behaviour per the Stacked Borrows model:

  • Casting &JsString to &mut RawJsString to &[u16]. The intermediate mutable borrow must not exist, or Miri considers this as Undefined Behaviour.
  • Trying to access RawJsString.data using the dot operator. Miri complains with this is a zero-size retag ([0x10..0x10]) so the tag in question does not exist anywhere. To fix this, we can recompute the position of data every time we want to access it.

@jedel1043 jedel1043 added the Internal Category for changelog label Nov 6, 2022
@jedel1043 jedel1043 added this to the v0.17.0 milestone Nov 6, 2022
@github-actions
Copy link

github-actions bot commented Nov 6, 2022

Test262 conformance changes

Test result main count PR count difference
Total 93,789 93,789 0
Passed 69,500 69,500 0
Ignored 18,422 18,422 0
Failed 5,867 5,867 0
Panics 0 0 0
Conformance 74.10% 74.10% 0.00%

@codecov
Copy link

codecov bot commented Nov 6, 2022

Codecov Report

Merging #2412 (61805f1) into main (8e14d76) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@           Coverage Diff           @@
##             main    #2412   +/-   ##
=======================================
  Coverage   38.41%   38.42%           
=======================================
  Files         313      313           
  Lines       23974    23982    +8     
=======================================
+ Hits         9210     9214    +4     
- Misses      14764    14768    +4     
Impacted Files Coverage Δ
boa_engine/src/string/mod.rs 57.82% <50.00%> (-1.31%) ⬇️
boa_ast/src/property.rs 18.96% <0.00%> (-1.73%) ⬇️
boa_engine/src/builtins/bigint/mod.rs 71.69% <0.00%> (-0.53%) ⬇️
boa_engine/src/builtins/object/mod.rs 56.56% <0.00%> (-0.37%) ⬇️
boa_engine/src/vm/mod.rs 42.74% <0.00%> (-0.35%) ⬇️
boa_engine/src/value/mod.rs 49.82% <0.00%> (-0.18%) ⬇️
boa_engine/src/bytecompiler/mod.rs 29.44% <0.00%> (-0.05%) ⬇️
boa_engine/src/builtins/function/mod.rs 25.13% <0.00%> (+0.13%) ⬆️
boa_engine/src/builtins/json/mod.rs 69.50% <0.00%> (+0.19%) ⬆️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@raskad
Copy link
Member

raskad commented Nov 6, 2022

bors r+

@bors
Copy link

bors bot commented Nov 6, 2022

Already running a review

bors bot pushed a commit that referenced this pull request Nov 6, 2022
This PR rewrites some patterns of the `JsString` implementation in order to pass all its miri tests. This can be verified by running:

```bash
cargo +nightly miri test -p boa_engine string::tests -- --skip builtins --skip parser
```

Basically, we were doing two operations that were Undefined Behaviour per the [Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md) model:
- Casting `&JsString` to `&mut RawJsString` to `&[u16]`. The intermediate mutable borrow must not exist, or Miri considers this as Undefined Behaviour.
- Trying to access `RawJsString.data` using the dot operator. Miri complains with `this is a zero-size retag ([0x10..0x10]) so the tag in question does not exist anywhere`. To fix this, we can recompute the position of `data` every time we want to access it.
@bors
Copy link

bors bot commented Nov 6, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Make JsString conform to miri tests [Merged by Bors] - Make JsString conform to miri tests Nov 6, 2022
@bors bors bot closed this Nov 6, 2022
@bors bors bot deleted the miri-string branch November 6, 2022 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants