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(speech/api): prevent segfault when arguments aren't parsed correctly #254

Merged
merged 6 commits into from
Oct 4, 2023

Conversation

alevenberg
Copy link
Member

@alevenberg alevenberg commented Oct 4, 2023

Prevent #252 from occurring

To verify, pass in command with an extra '-' so the arguments don't correctly parse:

pushd speech/api   
cmake -S. -B.build -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .build       
GOOGLE_CLOUD_CPP_USER_PROJECT=alevenb-test .build/streaming_transcribe_singlethread ---bitrate 16000 resources/audio.raw
❯ GOOGLE_CLOUD_CPP_USER_PROJECT=alevenb-test .build/streaming_transcribe_singlethread ---bitrate 16000 resources/audio.raw
Standard C++ exception thrown: unrecognised option '---bitrate'
Usage:
  streaming_transcribe_singlethread [--bitrate N] audio.(raw|ulaw|flac|amr|awb)

No more segfaulting 🥳

@alevenberg alevenberg requested a review from a team as a code owner October 4, 2023 13:35
@alevenberg alevenberg enabled auto-merge (squash) October 4, 2023 13:40
@alevenberg alevenberg changed the title fix(speech/api): move parse args before creating thread fix(speech/api): prevent segfault when arguments aren't parsed correctly Oct 4, 2023
@@ -30,7 +30,7 @@ using RecognizeStream = ::google::cloud::AsyncStreamingReadWriteRpc<
speech::v1::StreamingRecognizeResponse>;

auto constexpr kUsage = R"""(Usage:
streaming_transcribe_singlethread [--bitrate N] audio.(raw|ulaw|flac|amr|awb)
streaming_transcribe_coroutines [--bitrate N] audio.(raw|ulaw|flac|amr|awb)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@alevenberg alevenberg enabled auto-merge (squash) October 4, 2023 14:16
@alevenberg alevenberg merged commit 9e39e76 into GoogleCloudPlatform:main Oct 4, 2023
6 checks passed
@alevenberg alevenberg deleted the fix2 branch October 4, 2023 14:46
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