Skip to content

python: fix segfault on empty argv in main() #2003

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

senyai
Copy link
Contributor

@senyai senyai commented Jun 15, 2025

test:
python -c 'import google_benchmark as b;b.register(print);b.main([]);'

@senyai senyai force-pushed the senyai-fix-empty-args branch from d9d0138 to 82f5ae1 Compare June 15, 2025 17:18
@senyai senyai force-pushed the senyai-fix-empty-args branch from 82f5ae1 to 7fe6010 Compare June 15, 2025 18:07
@senyai
Copy link
Contributor Author

senyai commented Jun 15, 2025

I think there's more explicit and expressive way to update the logic:

if (!argv.empty()) {
  static std::string executable_name(argv[0]);
  ptrs[0] = const_cast<char*>(executable_name.c_str());
}

should I change it, @LebedevRI?

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 this pull request may close these issues.

2 participants