-
-
Save agentzh/93f1624ecb4f2e178b4db776fc4e0dcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit f32f2770642109b85fadabd855ce064f42f710ed (HEAD -> master) | |
Author: Sultan Alsawaf <sultan@openresty.com> | |
Date: Thu Oct 29 01:20:31 2020 -0700 | |
task_finder: error out when we cannot attach to _stp_target | |
In order to avoid sleeping, stap_find_exe_file() does a trylock attempt | |
on an mm's mmap semaphore and returns NULL when the lock is contented. | |
When this happens, it can cause the task finder to not attach to a | |
desired target process. This is especially noticeable when a target PID | |
is specified, in which case the target PID itself can get skipped over | |
by the task finder. | |
Therefore, we should treat failures to get the exe file for a specific | |
target PID as fatal, since that means the target PID will never get | |
attached. Note that we must return a negative value from | |
stap_start_task_finder() in order for the fatal error to be honored, so | |
we shouldn't negate PTR_ERR(mmpath). | |
Signed-off-by: Yichun Zhang (agentzh) <yichun@openresty.com> | |
diff --git a/po/en.gmo b/po/en.gmo | |
index 1f3bb4290..16c56b0dc 100644 | |
Binary files a/po/en.gmo and b/po/en.gmo differ | |
diff --git a/po/fr.gmo b/po/fr.gmo | |
index 3daa003f5..6d4df7307 100644 | |
Binary files a/po/fr.gmo and b/po/fr.gmo differ | |
diff --git a/runtime/linux/task_finder.c b/runtime/linux/task_finder.c | |
index 62a872624..8b95f3e1a 100644 | |
--- a/runtime/linux/task_finder.c | |
+++ b/runtime/linux/task_finder.c | |
@@ -1684,8 +1684,11 @@ stap_start_task_finder(void) | |
mmpath = __stp_get_mm_path(tsk->mm, mmpath_buf, PATH_MAX); | |
task_unlock(tsk); | |
if (mmpath == NULL || IS_ERR(mmpath)) { | |
- rc = -PTR_ERR(mmpath); | |
- if (rc == ENOENT) { | |
+ rc = PTR_ERR(mmpath); | |
+ /* If this was our target then it's a fatal error */ | |
+ if (!_stp_target && rc == -ENOENT) { | |
+ _stp_warn("Unable to get path (error %d) for pid %d", | |
+ rc, (int)tsk->pid); | |
rc = 0; /* ignore ENOENT */ | |
continue; | |
} | |
diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c | |
index 8b8057a0e..93b7e2131 100644 | |
--- a/runtime/linux/task_finder2.c | |
+++ b/runtime/linux/task_finder2.c | |
@@ -1803,8 +1803,11 @@ stap_start_task_finder(void) | |
mmpath = __stp_get_mm_path(tsk->mm, mmpath_buf, PATH_MAX); | |
task_unlock(tsk); | |
if (mmpath == NULL || IS_ERR(mmpath)) { | |
- rc = -PTR_ERR(mmpath); | |
- if (rc == ENOENT) { | |
+ rc = PTR_ERR(mmpath); | |
+ /* If this was our target then it's a fatal error */ | |
+ if (!_stp_target && rc == -ENOENT) { | |
+ _stp_warn("Unable to get path (error %d) for pid %d", | |
+ rc, (int)tsk->pid); | |
rc = 0; /* ignore ENOENT */ | |
continue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment