Skip to content

Make sure size_test CI uses -Wall -Werror #8016

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
merged 1 commit into from
Feb 11, 2025
Merged

Make sure size_test CI uses -Wall -Werror #8016

merged 1 commit into from
Feb 11, 2025

Conversation

mergennachin
Copy link
Contributor

@mergennachin mergennachin commented Jan 28, 2025

I am not changing the default compilation option for all of ExecuTorch. I'm only changing the compile option for size_test and size_test_all_ops tests.

We don't run size_test for Windows, at least for today

Test Plan:

Run sh test/build_size_test.sh
Add op_fill.cpp with this patch at the end of the file.

int x;
printf("%d", x); // x is uninitialized

Make sure the compilation fails, https://gist.github.com/mergennachin/25b78c63069b9e9b2203e66f94b1a0be

Make sure the compilation succeeds without the "-Wall -Werror" flags.

Copy link

pytorch-bot bot commented Jan 28, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8016

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 Jan 28, 2025
@mergennachin mergennachin requested a review from swolchok January 28, 2025 21:35
@mergennachin
Copy link
Contributor Author

Continuing where I left off: #7940

Not changing CMakeLists.txt this time.

Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

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

love it

@swolchok
Copy link
Contributor

I don't see size_test in the CI jobs?

@mergennachin
Copy link
Contributor Author

mergennachin commented Jan 29, 2025

I don't see size_test in the CI jobs?

Just rebased (which contain CI fixes)

size_test for clang12 passed, but not for gcc9

https://github.com/pytorch/executorch/actions/runs/13022554836/job/36326025227?pr=8016

@@ -135,7 +135,7 @@ void make_kernel_key_string(Span<const TensorMeta> key, char* buf) {
// If no tensor is present in an op, kernel key does not apply
return;
}
strncpy(buf, "v1/", 3);
strcpy(buf, "v1/");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/pytorch/executorch/runtime/kernel/operator_registry.cpp:187:3: note: in expansion of macro 'ET_LOG_TENSOR_META'
  187 |   ET_LOG_TENSOR_META(meta_list);
      |   ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:535,
                 from /usr/include/c++/9/cstring:42,
                 from /pytorch/executorch/../executorch/runtime/kernel/operator_registry.h:11,
                 from /pytorch/executorch/runtime/kernel/operator_registry.cpp:9:
In function 'char* strncpy(char*, const char*, size_t)',
    inlined from 'void executorch::runtime::internal::make_kernel_key_string(executorch::runtime::Span<const executorch::runtime::TensorMeta>, char*)' at /pytorch/executorch/runtime/kernel/operator_registry.cpp:138:10:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:34: error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation]

Copy link
Contributor

Choose a reason for hiding this comment

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

the warning here was unhelpful IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this just be memcpy(buf, "v1/", 3);? Or are we relying on the NUL byte that strcpy adds?

Copy link
Contributor

Choose a reason for hiding this comment

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

I completely rewrote this function in #8327, so watch out for merge conflicts (if mine lands first)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, thanks for the heads up, will be careful during rebase

@mergennachin
Copy link
Contributor Author

  • Ignore 'sign-compare' but created a follow-up issue Compile with -Wsign-compare flag #8149
  • Fixed an error that was erroring with -Werror=stringop-truncation
  • Modified the CONTRIBUTION.md file to build the size_test information

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@@ -38,7 +38,8 @@ Tensor& full_out(

ET_SWITCH_SCALAR_OBJ_TYPES(val_type, ctx, name, CTYPE_VAL, [&] {
CTYPE_VAL val;
utils::extract_scalar(fill_value, &val);
ET_KERNEL_CHECK(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think ET_KERNEL_CHECK will do the right thing in a lambda -- it returns from the lambda, not the operator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any suggestions on how to fix?

i think it's fine, since it will return void from the lambda, but sets context to be fail, with error code InvalidArgument.

@@ -38,7 +38,8 @@ Tensor& full_out(

ET_SWITCH_SCALAR_OBJ_TYPES(val_type, ctx, name, CTYPE_VAL, [&] {
CTYPE_VAL val;
utils::extract_scalar(fill_value, &val);
ET_KERNEL_CHECK(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think ET_KERNEL_CHECK will do the right thing in a lambda -- it returns from the lambda, not the operator

@@ -135,7 +135,7 @@ void make_kernel_key_string(Span<const TensorMeta> key, char* buf) {
// If no tensor is present in an op, kernel key does not apply
return;
}
strncpy(buf, "v1/", 3);
strcpy(buf, "v1/");
Copy link
Contributor

Choose a reason for hiding this comment

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

the warning here was unhelpful IMO

@@ -11,11 +11,14 @@ set -e
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"

# Remove -Wno-sign-compare (https://github.com/pytorch/executorch/issues/8149)
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean to put a TODO here?

@swolchok
Copy link
Contributor

swolchok commented Feb 8, 2025

@mergennachin do you need anything else from me on this one?

@mergennachin
Copy link
Contributor Author

mergennachin commented Feb 10, 2025

@mergennachin do you need anything else from me on this one?

@swolchok, @dbort

i don't think we have come to a resolution on errors on boolean errors:

https://github.com/pytorch/executorch/actions/runs/13123890485/job/36616081625?pr=8016

i can specialize for boolean cases, and use &&=

@swolchok
Copy link
Contributor

&&= does not exist; you'd need &=. IMO such a change would be clear uglification of the code only to suppress a warning

@mergennachin
Copy link
Contributor Author

such a change would be clear uglification of the code only to suppress a warning

But it's a legitimate warning, no? You can today pass in a random memory location and define it as "boolean" tensor, which will cause some undefined behavior.

unless you pass in UBSAN flag

@swolchok
Copy link
Contributor

swolchok commented Feb 10, 2025

I don't think the code change you are considering would address the issue you just raised above.

@mergennachin
Copy link
Contributor Author

Okay, I will suppress that error for now and create a follow-up issue to track it

@mergennachin mergennachin force-pushed the wall branch 3 times, most recently from 8b9425b to 0c82c8b Compare February 11, 2025 01:32
@mergennachin mergennachin marked this pull request as ready for review February 11, 2025 01:40
@facebook-github-bot
Copy link
Contributor

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

@mergennachin mergennachin merged commit 4e6abf8 into main Feb 11, 2025
104 checks passed
@mergennachin mergennachin deleted the wall branch February 11, 2025 02:31
b_shape_str.data());
tensor_shape_to_c_string(a_size_span).data(),
tensor_shape_to_c_string(b_size_span).data());
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@swolchok
Copy link
Contributor

@mergennachin it seems suboptimal for us to enforce -Wall -Werror, but only in a CI job that runs only on trunk, as this will result in unnecessarily-delayed detection of broken trunk. could we perhaps have a pull-time CI job that builds with these flags?

@swolchok
Copy link
Contributor

e.g. #8314 promptly broke this on trunk because of -Werror

@mergennachin
Copy link
Contributor Author

@swolchok test-binary-size is a pull job

perhaps, in this #8314 case your base commit was old and it didn't catch during PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants