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 segfault on arm64 #253

Merged
merged 1 commit into from
May 15, 2023
Merged

Fix segfault on arm64 #253

merged 1 commit into from
May 15, 2023

Conversation

nsavoire
Copy link
Collaborator

@nsavoire nsavoire commented May 12, 2023

On arm64, pthread_attr_t is bigger in glibc than in musl. Consequently when pthread_getattr_np zeroes the struct, it writes out-of-bounds.
Dirty fix is to add some padding at the end of the struct, this works because additional space present in glibc is not actually used.

@nsavoire nsavoire force-pushed the nsavoire/fix_arm64_segfault branch from 91a7be0 to d2ebe23 Compare May 12, 2023 18:43
src/lib/pthread_fixes.cc Show resolved Hide resolved
src/lib/pthread_fixes.cc Show resolved Hide resolved
sanchda
sanchda previously approved these changes May 12, 2023
@r1viollet
Copy link
Collaborator

Thanks for the fix!
Minor warning with unused field from cppcheck

cppcheck:unusedStructMember:/go/src/github.com/DataDog/apm-reliability/ddprof-build/ddprof/src/lib/pthread_fixes.cc:43:style:union member 'pthread_attr_safe_t::reserved' is never used.

On arm64, pthread_attr_t is bigger in glibc than in musl.
Consequently when pthread_getattr_np zeroes the struct, it
writes out-of-bounds.
Dirty fix is to add some padding at the end of the struct,
this works because additional space present in glibc is not
actually used.
Copy link
Collaborator

@r1viollet r1viollet left a comment

Choose a reason for hiding this comment

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

LGTM

@r1viollet r1viollet merged commit 5b6e50c into main May 15, 2023
@nsavoire nsavoire deleted the nsavoire/fix_arm64_segfault branch May 15, 2023 08:33
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.

3 participants