flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[C++] Rare bad buffer content alignment if sizeof(T) != alignof(T)

Open Naios opened this issue 3 years ago • 2 comments

EDIT: Fix for https://github.com/google/flatbuffers/issues/7516, see below

Naios avatar Sep 10 '22 10:09 Naios

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Sep 10 '22 10:09 google-cla[bot]

@dbaileychess Could you review this PR please?

I fixed the issue by adding alignment parameters to functions calling StartVector.

Additionally, I spotted several expressions in the codebase of the form array_length = len * sizeof(T) / AlignOf<T>() that do not seem right to me and might need a correction.

Naios avatar Sep 13 '22 09:09 Naios

@Naios You need to add your new file to the bazel build rule, its failing CI: https://github.com/google/flatbuffers/blob/master/tests/BUILD.bazel#L7

dbaileychess avatar Sep 15 '22 00:09 dbaileychess

Generally looks good to me.

dbaileychess avatar Sep 15 '22 00:09 dbaileychess

@dbaileychess Thank you for your review, I have fixed the outstanding changes and optimizations.

Naios avatar Sep 15 '22 08:09 Naios

@dbaileychess From my side this PR is finished, do you know why workflow "buildkite/flatbuffers/pr" is failing without any useful output?

Naios avatar Sep 19 '22 11:09 Naios

Build kite error:

:bazel: buildifier: found 1 format issue in your WORKSPACE, BUILD and *.bzl files
Please download [buildifier 5.1.0](https://github.com/bazelbuild/buildtools/releases/tag/5.1.0) and run the following command in your workspace:

buildifier tests/BUILD.bazel

Looks like you placed the deps out of alphanumeric order.

dbaileychess avatar Sep 21 '22 04:09 dbaileychess

The fuzzer build is failing too, looks like due to stricter warnings on the deprecated method. Can you see if the deprecated method is being used in the fuzzer to fix it?

dbaileychess avatar Sep 21 '22 04:09 dbaileychess

@dbaileychess I probably have fixed the remaining issues, could you approve the outstanding workflows again please?

Naios avatar Sep 21 '22 17:09 Naios

Thanks a bunch!

dbaileychess avatar Sep 21 '22 18:09 dbaileychess