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

bofObjectRunAsyncThread() crashes with older GLIBC versions #3

Closed
fermat-prime opened this issue May 15, 2024 · 1 comment
Closed

Comments

@fermat-prime
Copy link
Contributor

Calling bofObjectRunAsyncThread() on a system with an older GLIBC versions (prior to 2.34) will cause a segmentation fault due to a NULL pointer dereference. This is because pthread functionality wasn't integrated into libc.so.6 in those GLIBC versions so the pthread_create and pthread_detach function pointers are NULL.

This should be reproducible by modifying the integration-with-c example to use bofObjectRunAsyncThread (demo.patch) and executing it on a system with an older GLIBC. I also have an example fix that patches bof_launcher.zig to load the functions from libpthread.so.0 (fix.patch).

demo.zip

test@test:~$ unzip demo.zip
Archive:  demo.zip
  inflating: demo.sh                 
  inflating: demo.patch              
  inflating: fix.patch
  
# run an example that produces a crash 
test@test:~$ docker run --rm -it --entrypoint bash -v`pwd`:/data oraclelinux:8.9 /data/demo.sh

# run the example with the example fix applied
test@test:~$ docker run --rm -it --entrypoint bash -v`pwd`:/data oraclelinux:8.9 /data/demo.sh 1

I have tested this patch on GLIBC 2.17, 2.28, 2.34, and 2.39 and the patch worked in all cases. However, I have only been able to test x86_64 and not architectures such as arm or aarch64.

I don't know if introducing a reliance on libpthread.so.0 (or the stub provided with modern GLIBC versions) is how you wanted to address this until issue #1 is solved so I didn't want to preemptively make a pull request. Let me know if you would like me to make one though.

Thanks for making and maintaining this project, I've found it to be quite interesting and useful!

@michal-z
Copy link
Collaborator

Thanks for the report.

I think that your patch is a good temporary solution until #1 is solved. Please make a PR and @mzet- will test it on ARM.

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

No branches or pull requests

2 participants