Skip to content

fix: Aggregate destroyAccumulator memset call with dynamic class input#14568

Closed
nmahadevuni wants to merge 1 commit intofacebookincubator:mainfrom
nmahadevuni:fix_accumulator_memset
Closed

fix: Aggregate destroyAccumulator memset call with dynamic class input#14568
nmahadevuni wants to merge 1 commit intofacebookincubator:mainfrom
nmahadevuni:fix_accumulator_memset

Conversation

@nmahadevuni
Copy link
Collaborator

If we use a dynamic class in the Accumulator, then the memset call in destroyAccumulator fails during build with

velox/velox/exec/Aggregate.h:437:16: error: destination for this 'memset' call is a pointer to class containing a dynamic class 'update_theta_sketch_alloc<std::allocator<unsigned long long>>'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]
  437 |       ::memset(accumulator, 0, sizeof(T));

Encountered this when working on prestodb/presto#25685

@meta-cla meta-cla 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 Aug 22, 2025
@netlify
Copy link

netlify bot commented Aug 22, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 97804af
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/68ab36a7e827d600080122ab

auto accumulator = value<T>(group);
std::destroy_at(accumulator);
::memset(accumulator, 0, sizeof(T));
::memset((void*)accumulator, 0, sizeof(T));
Copy link
Contributor

Choose a reason for hiding this comment

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

The style guidance is to use static_cast

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @Yuhta, @aditi-pandit for the review. I have addressed the comment. Please review.

@nmahadevuni nmahadevuni force-pushed the fix_accumulator_memset branch from c128b05 to 97804af Compare August 24, 2025 15:58
@nmahadevuni
Copy link
Collaborator Author

@Yuhta Can you please review this?

@facebook-github-bot
Copy link
Contributor

@Yuhta has imported this pull request. If you are a Meta employee, you can view this in D81692109.

@facebook-github-bot
Copy link
Contributor

@Yuhta merged this pull request in c12e666.

nimesh1601 pushed a commit to nimesh1601/velox that referenced this pull request Sep 10, 2025
facebookincubator#14568)

Summary:
If we use a dynamic class in the Accumulator, then the `memset` call in `destroyAccumulator` fails during build with
```
velox/velox/exec/Aggregate.h:437:16: error: destination for this 'memset' call is a pointer to class containing a dynamic class 'update_theta_sketch_alloc<std::allocator<unsigned long long>>'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]
  437 |       ::memset(accumulator, 0, sizeof(T));
```

Encountered this when working on prestodb/presto#25685

Pull Request resolved: facebookincubator#14568

Reviewed By: xiaoxmeng

Differential Revision: D81692109

Pulled By: Yuhta

fbshipit-source-id: 55fc80cfde5a339d8c39b211c062a374013037cd
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants