runtime/cgo: add assertions for safe stack retrieval on unix #71897
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
runtime/cgo: add assertions for safe stack retrieval on Unix
This change introduces assertions (
assert()
) to verify the returnvalues of
pthread
function calls ingcc_stack_unix.c
. This improveserror detection and ensures failures in stack attribute retrieval are
caught early.
Changes:
#include <assert.h>
to include theassert()
function.pthread_attr_init
,pthread_getattr_np
,pthread_attr_get_np
,and
pthread_attr_getstack
calls withassert()
to ensure successfulexecution.
functions might fail silently.
Rationale:
pthread
functions execute successfully prevents undefinedbehavior caused by uninitialized or incorrect stack attributes.
assert()
helps catch errors in debug builds, aiding introubleshooting potential issues early in development.
Testing:
Fixes #71896
Change-Id: Ice10a4b506466e05720d7d45dc609bba75c49109
GitHub-Last-Rev: 0302d11
GitHub-Pull-Request: #71897