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 primitives benchmark code #812

Merged

Conversation

gigony
Copy link
Contributor

@gigony gigony commented Jan 15, 2025

The pointer variable is used after releasing memory with free(), which is a bug that needs to be addressed.

Without this fix, the benchmark code may fail to build or run correctly, resulting in the following error (link)

In function 'void benchmark::DoNotOptimize(Tp&) [with Tp = char*]',
    inlined from 'void string_strcpy(benchmark::State&)' at /opt/conda/conda-bld/work/benchmarks/primitives.cpp:110:33:
/opt/conda/conda-bld/work/build-release/_deps/deps-googlebenchmark-src/src/../include/benchmark/benchmark.h:322:3: error: pointer used after 'void free(void*)' [-Werror=use-after-free]
  322 |   asm volatile("" : "+m,r"(value) : : "memory");
      |   ^~~

It seems that the updated version of GCC is now capable of detecting this potential issue.

This commit resolves the issue by ensuring the memory is released only after benchmark::DoNotOptimize() is called.

This PR handles a build issue related to #811

Pointer variable is used after releasing the memory with free().
This is a bug and should be fixed.

Without this fix, the benchmark code may not build or run correctly.
  error: pointer used after 'void free(void*)' [-Werror=use-after-free]

This commit fixes the issue by releasing the memory after
benchmark::DoNotOptimize() is called.
@gigony gigony added bug Something isn't working non-breaking Introduces a non-breaking change labels Jan 15, 2025
@gigony gigony requested review from jakirkham and bdice January 15, 2025 22:42
@gigony gigony self-assigned this Jan 15, 2025
@jakirkham
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit fa6a558 into rapidsai:branch-25.02 Jan 16, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants