Skip to content

Conversation

@Jongy
Copy link
Contributor

@Jongy Jongy commented Sep 6, 2022

I added a helper is_process_basename which checks both the comm & argv[0], then fixed all relevant sites to use it.

EDIT: manual tests described ahead, but I also added automatic tests for it.

To test, I applied this diff:

diff --git a/tests/containers/java/Dockerfile b/tests/containers/java/Dockerfile
index c2e6a74..e6c802f 100644
--- a/tests/containers/java/Dockerfile
+++ b/tests/containers/java/Dockerfile
@@ -7,5 +7,6 @@ ADD Fibonacci.java /app
 ADD MANIFEST.MF /app
 RUN javac Fibonacci.java
 RUN jar cvmf MANIFEST.MF Fibonacci.jar *.class
+RUN cp `which java` `which java`xxx
 
-CMD ["sh", "-c", "java -jar Fibonacci.jar; sleep 10000"]
+CMD ["bash", "-c", "exec -a java javaxxx -jar Fibonacci.jar; sleep 10000"]

Before this branch:

[2022-09-06 22:12:39,801] WARNING: gprofiler.profilers.java: Non-java basenamed process (cannot get Java version), skipping... (disable  --java-safemode=java-extended-version-checks to profile it anyway) (pid=1185956, exe=/usr/local/openjdk-8/bin/javaxxx)

After - process is profiled fine, and I get stacks like:

1;recursing_bell;javaxxx;appid: java: Fibonacci.jar;Fibonacci$1.run()V_[j];java/io/File.list()[Ljava/lang/String|_[j];java/io/UnixFileSystem.list(Ljava/io/File|)[Ljava/lang/String|_[j];[unknown];/lib/x86_64-linux-gnu/libc-2.28.so;entry_SYSCALL_64_after_hwframe_[k];do_syscall_64_[k];syscall_exit_to_user_mode_[k];exit_to_user_mode_prepare_[k];exit_to_user_mode_loop_[k];task_work_run_[k];____fput_[k];__fput_[k];security_file_free_[k];kmem_cache_free_[k];slab_free_freelist_hook.constprop.0_[k] 1

Along the way, this fixes at least one usage of process.exe() which is problematic (should use process_exe()).

@Jongy Jongy added the enhancement New feature or request label Sep 6, 2022
@Jongy Jongy requested a review from michelhe September 6, 2022 22:16
@Jongy Jongy requested a review from michelhe September 11, 2022 08:55
@Jongy
Copy link
Contributor Author

Jongy commented Sep 15, 2022

Flaky failure - documented inhttps://github.com//issues/462

@Jongy Jongy merged commit 44b00bf into master Sep 15, 2022
@Jongy Jongy deleted the basename-in-args branch September 15, 2022 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants