Skip to content

Conversation

@rectified95
Copy link

@rectified95 rectified95 commented Apr 14, 2021

Summary

Recent changes to MapBuffer have broken the compilation on Windows.
This fix is similar to this recently-merged change: #31106

Side note - this PR only addresses a build break, but doesn't address the unsafe casting semantics in MapBuffer, which can still cause overflows.

Changelog

[General] [Fixed] - Fix compilation errors on Windows.

Test Plan

RN now builds in Visual Studio on Windows.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 14, 2021
@rectified95 rectified95 requested review from mdvacca and rozele April 14, 2021 22:32
@rectified95 rectified95 added p: Microsoft Partner: Microsoft Platform: Windows Building on Windows. labels Apr 14, 2021
@analysis-bot
Copy link

analysis-bot commented Apr 14, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,863,406 +175
android hermes armeabi-v7a 8,385,791 +105
android hermes x86 9,321,036 +125
android hermes x86_64 9,264,774 +126
android jsc arm64-v8a 10,592,518 +170
android jsc armeabi-v7a 10,098,001 +99
android jsc x86 10,611,669 +152
android jsc x86_64 11,195,648 +122

Base commit: 2b49664

@analysis-bot
Copy link

analysis-bot commented Apr 15, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 9e020ef

@asklar
Copy link
Contributor

asklar commented Apr 15, 2021

It would be good to add some CI that this type of stuff isn't regressed since it seems fragile and breaks us every time someone forgets to use the right cast (or otherwise deal with the overflow) :)
@rozele is there appetite for setting up some CI so that changes that will break downstream can be caught before they are merged?

@NickGerleman
Copy link
Contributor

NickGerleman commented Apr 15, 2021

Maybe we can enable equivalent Clang warnings when building with BUCK? I.e. enable the same warnings for internal usage on iOS/Android.

This sort of thing is going to happen if warnings are mismatched between repos. If we've decided we care about SDL warnings, I think our team should look at what is needed to keep similar warnings clean upstream.

@NickGerleman
Copy link
Contributor

I do think this is something our team has some responsibility for. We have stricter warnings, and realized there are warnings we no longer want to disable in upstream code. It's great we were able to get things clean, but keeping things clean long term is always the hard part that needs enforcement.

@NickGerleman
Copy link
Contributor

Something that I think we could use help with is upstreaming any additional fixes. E.g. Yoga no longer responds to external PRs, so there have been fixes we haven't been able to do anything with there.

@facebook-github-bot
Copy link
Contributor

@rozele has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

int32_t bufferSize = keyValuesOffset_ + dynamicDataOffset_;

_header.bufferSize = bufferSize;
_header.bufferSize = static_cast<uint16_t>(bufferSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

I came across this and I'm not certain truncating to 16 bit is correct behavior. There was a recent change to move more of this class to use int32_t though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to test removing this + the case below locally in RNW. Though the above still makes sense (since string length is size_t).

Copy link
Author

Choose a reason for hiding this comment

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

This indeed now builds without these 2 casts - removing.
Still, this gets implicitly cast to a narrower data type - OOC why do you think explicit casting is wrong here?

@rectified95
Copy link
Author

@rozele I think this is in a state it should be now.

@facebook-github-bot
Copy link
Contributor

@rozele has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@rozele merged this pull request in 6d04a46.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Microsoft Partner: Microsoft Platform: Windows Building on Windows.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants