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 CI target for Fedora #152

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ jobs:
g++ \
file \
python3 \
python3-devel \
python3-debug
python3-devel
dnf debuginfo-install -y \
python3
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
Expand Down
17 changes: 14 additions & 3 deletions src/pystack/_pystack/pythread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,20 @@ findPthreadTidOffset(
auto pthread_id_addr = manager->getField(current_thread, &py_thread_v::o_thread_id);

// Attempt to locate a field in the pthread struct that's equal to the pid.
uintptr_t buffer[200];
manager->copyObjectFromProcess(pthread_id_addr, &buffer);
for (int i = 0; i < 200; i++) {
uintptr_t buffer[100];
size_t buffer_size = sizeof(buffer);
while (buffer_size > 0) {
try {
LOG(DEBUG) << "Trying to copy a buffer of " << buffer_size << " bytes to get pthread ID";
manager->copyMemoryFromProcess(pthread_id_addr, buffer_size, &buffer);
break;
} catch (const RemoteMemCopyError& ex) {
LOG(DEBUG) << "Failed to copy buffer to get pthread ID";
buffer_size /= 2;
}
}
LOG(DEBUG) << "Copied a buffer of " << buffer_size << " bytes to get pthread ID";
for (int i = 0; i < buffer_size / sizeof(uintptr_t); i++) {
if (static_cast<pid_t>(buffer[i]) == manager->Pid()) {
off_t offset = sizeof(uintptr_t) * i;
LOG(DEBUG) << "Tid offset located by scanning at offset " << std::showbase << std::hex
Expand Down
Loading