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

[FR] clang static analyzer: src/include/benchmark/benchmark.h:1069:3: Potential memory leak [cplusplus.NewDeleteLeaks] #1513

Closed
LebedevRI opened this issue Nov 29, 2022 · 8 comments · Fixed by #1618

Comments

@LebedevRI
Copy link
Collaborator

https://github.com/darktable-org/rawspeed/actions/runs/3574871458/jobs/6011864553#step:23:314

inline internal::Benchmark* RegisterBenchmark(const char* name,
internal::Function* fn) {
return internal::RegisterBenchmarkInternal(
::new internal::FunctionBenchmark(name, fn));
}

triggers clang static analyzer reports:

[HIGH] /__w/rawspeed/rawspeed/rawspeed-build/src/external/googlebenchmark/src/include/benchmark/benchmark.h:1069:3: Potential memory leak [cplusplus.NewDeleteLeaks]
  return internal::RegisterBenchmarkInternal(
  ^

Found 1 defect(s) in benchmark.h

It would be really good to either completely rewrite that code to avoid the issue in the first place,
or at least silence it as a known false-positive.

@HFTrader
Copy link
Contributor

HFTrader commented Mar 8, 2023

I could not replicate this. Using clang 17 (trunk) and benchmark/main as of today.

@LebedevRI
Copy link
Collaborator Author

@dmah42
Copy link
Member

dmah42 commented Mar 8, 2023

can we add that static analysis to the benchmark CI bots?

@LebedevRI
Copy link
Collaborator Author

Still happening: https://github.com/darktable-org/rawspeed/actions/runs/4367100895/jobs/7637984919#step:29:275

(Err, of course that is with clang-15, maybe it's gone in clang-16, i don't know yet.)

@HFTrader
Copy link
Contributor

HFTrader commented Mar 8, 2023

How did you run? Just scan-build make?

@LebedevRI
Copy link
Collaborator Author

As you can see in that very log, by running CodeChecker over the compile_commands.json.

@HFTrader
Copy link
Contributor

It looks like CodeChecker uses scan-build under the hood, right? Let me try with clang-15 or earlier.

@LebedevRI
Copy link
Collaborator Author

Yup, the warning is still there with clang-16, as expected:
https://github.com/darktable-org/rawspeed/actions/runs/5428151349/jobs/9872094540?pr=494

Also, is anyone familiar why benchmarks that are linked to shared libraries
may fail with Exit code 0xc0000135?
https://github.com/darktable-org/rawspeed/actions/runs/5428151349/jobs/9872096202?pr=494

LebedevRI added a commit to LebedevRI/benchmark that referenced this issue Jul 1, 2023
LebedevRI added a commit to LebedevRI/benchmark that referenced this issue Jul 1, 2023
dmah42 added a commit that referenced this issue Jul 3, 2023
…c analysis (#1618)

#1513

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants