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 an apparent x86 miscompilation on MSVC 19.38 #16742

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Feb 21, 2024

There's an apparent miscompilation of dynamic_bitset on x86 with
MSVC 19.38, where the following code:

dynamic_bitset<uint64_t> bits(80 * 24, 0);
bits.set(0, 3 * 80, true);

is expected to set the first 3.75 blocks to 1 which should produce
the following blocks:

0xffffffffffffffff
0xffffffffffffffff
0xffffffffffffffff
0x0000ffffffffffff

but it actually produces:

0xffffffffffffffff
0x00000000ffffffff
0xffffffffffffffff
0x0000ffffffffffff

The weird thing here is that this only happens if til::bitmap
uses a dynamic_bitset<uint64_t>. As soon as it uses <uint32_t>
any other instantiation of <uint64_t> is magically fixed.

Conclusion: Use size_t until we know what's going on.
Last known good CL version: 14.37.32822
Current broken CL version: 14.38.33130

Validation Steps Performed

The following test completes successfully again:

til::bitmap map{ { 80, 24 } };
map.translate({ 0, 3 }, true);
VERIFY_ARE_EQUAL(3u, map.runs().size());

@lhecker lhecker added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Build Issues pertaining to the build system, CI, infrastructure, meta labels Feb 21, 2024
@lhecker lhecker modified the milestone: Terminal v1.19 Feb 21, 2024
@lhecker lhecker changed the title Fix a x86 miscompilation caused by MSVC 19.38 Fix an apparent x86 miscompilation on MSVC 19.38 Feb 21, 2024
@DHowett DHowett added the Needs-Second It's a PR that needs another sign-off label Feb 21, 2024
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wat

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Second It's a PR that needs another sign-off label Feb 21, 2024
@DHowett DHowett merged commit d3ec47a into main Feb 21, 2024
20 checks passed
@DHowett DHowett deleted the user/lhecker/fix-build-break branch February 21, 2024 17:54
DHowett pushed a commit that referenced this pull request Feb 21, 2024
There's an apparent miscompilation of `dynamic_bitset` on x86 with
MSVC 19.38, where the following code:
```cpp
dynamic_bitset<uint64_t> bits(80 * 24, 0);
bits.set(0, 3 * 80, true);
```

is expected to set the first 3.75 blocks to 1 which should produce
the following blocks:
```
0xffffffffffffffff
0xffffffffffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

but it actually produces:
```
0xffffffffffffffff
0x00000000ffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

The weird thing here is that this only happens if `til::bitmap`
uses a `dynamic_bitset<uint64_t>`. As soon as it uses `<uint32_t>`
any other instantiation of `<uint64_t>` is magically fixed.

Conclusion: Use `size_t` until we know what's going on.
Last known good CL version: 14.37.32822
Current broken CL version: 14.38.33130

## Validation Steps Performed

The following test completes successfully again:
```cpp
til::bitmap map{ { 80, 24 } };
map.translate({ 0, 3 }, true);
VERIFY_ARE_EQUAL(3u, map.runs().size());
```

(cherry picked from commit d3ec47a)
Service-Card-Id: 91885584
Service-Version: 1.20
DHowett pushed a commit that referenced this pull request Feb 21, 2024
There's an apparent miscompilation of `dynamic_bitset` on x86 with
MSVC 19.38, where the following code:
```cpp
dynamic_bitset<uint64_t> bits(80 * 24, 0);
bits.set(0, 3 * 80, true);
```

is expected to set the first 3.75 blocks to 1 which should produce
the following blocks:
```
0xffffffffffffffff
0xffffffffffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

but it actually produces:
```
0xffffffffffffffff
0x00000000ffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

The weird thing here is that this only happens if `til::bitmap`
uses a `dynamic_bitset<uint64_t>`. As soon as it uses `<uint32_t>`
any other instantiation of `<uint64_t>` is magically fixed.

Conclusion: Use `size_t` until we know what's going on.
Last known good CL version: 14.37.32822
Current broken CL version: 14.38.33130

## Validation Steps Performed

The following test completes successfully again:
```cpp
til::bitmap map{ { 80, 24 } };
map.translate({ 0, 3 }, true);
VERIFY_ARE_EQUAL(3u, map.runs().size());
```

(cherry picked from commit d3ec47a)
Service-Card-Id: 91885583
Service-Version: 1.19
@zadjii-msft zadjii-msft linked an issue Feb 22, 2024 that may be closed by this pull request
DHowett pushed a commit that referenced this pull request Mar 8, 2024
There's an apparent miscompilation of `dynamic_bitset` on x86 with
MSVC 19.38, where the following code:
```cpp
dynamic_bitset<uint64_t> bits(80 * 24, 0);
bits.set(0, 3 * 80, true);
```

is expected to set the first 3.75 blocks to 1 which should produce
the following blocks:
```
0xffffffffffffffff
0xffffffffffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

but it actually produces:
```
0xffffffffffffffff
0x00000000ffffffff
0xffffffffffffffff
0x0000ffffffffffff
```

The weird thing here is that this only happens if `til::bitmap`
uses a `dynamic_bitset<uint64_t>`. As soon as it uses `<uint32_t>`
any other instantiation of `<uint64_t>` is magically fixed.

Conclusion: Use `size_t` until we know what's going on.
Last known good CL version: 14.37.32822
Current broken CL version: 14.38.33130

## Validation Steps Performed

The following test completes successfully again:
```cpp
til::bitmap map{ { 80, 24 } };
map.translate({ 0, 3 }, true);
VERIFY_ARE_EQUAL(3u, map.runs().size());
```

(cherry picked from commit d3ec47a)
Service-Card-Id: 91894072
Service-Version: 1.18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Build Issues pertaining to the build system, CI, infrastructure, meta Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
Status: Cherry Picked
Development

Successfully merging this pull request may close these issues.

mangled output after update to 1.18.10301.0
3 participants