libfaketime icon indicating copy to clipboard operation
libfaketime copied to clipboard

Java processes with libfaketime do not stop when getting SIGTERM

Open eriknellessen opened this issue 1 year ago • 2 comments

When using the current Java 11 version (OpenJDK 11.0.21) in Ubuntu 22.04 and libfaketime 0.9.7-3ubuntu1, java processes do not stop anymore when getting the SIGTERM signal. I tried the following combinations (all in docker containers):

  • Ubuntu 22.04, OpenJDK 11.0.21, libfaketime 0.9.7-3ubuntu1 => The problem exists
  • Ubuntu 20.04, OpenJDK 11.0.21, libfaketime 0.9.7-3ubuntu1 => The problem exists
  • Ubuntu 22.04, OpenJDK 11.0.18, libfaketime 0.9.7-3ubuntu1 => The problem does not exist
  • Ubuntu 22.04, OpenJDK 1.8.0_392, libfaketime 0.9.7-3ubuntu1 => The problem does not exist
  • Ubuntu 20.04, OpenJDK 1.8.0_392, libfaketime 0.9.7-3ubuntu1 => The problem does not exist

When taking a look at the process threads, I could see a lot of SIGTERM handlers: sigterm_libfaketime

This issue might look similar to this already existing issue: https://github.com/wolfcw/libfaketime/issues/428 But it is not the same problem. We are not using the faketime binary, but the mechanism with the configuration file /etc/ld.so.preload. The other issue is not about java programs, but a problem that generally occurs when using the faketime binary.

eriknellessen avatar Dec 12 '23 13:12 eriknellessen

Are you preloading libfaketime.so or libfaketimeMT.so? If the latter, could you try compiling without -DPTHREAD_SINGLETHREADED_TIME in the Makefile and check whether that makes any difference?

libfaketime itself does not establish any signal handlers and thus couldn't get locked up in any of them. Are there any changes in OpenJDK's SIGTERM handler between the two versions?

wolfcw avatar Dec 12 '23 20:12 wolfcw

We are preloading libfaketime.so (it is called libfaketime.so.1 in Ubuntu). I could not find any hints about the SIGTERM handler in the release notes of OpenJDK 11.0.19, OpenJDK 11.0.20 and OpenJDK 11.0.21. I should add that I am not an expert concerning the OpenJDK release notes, so it is possible that I missed something. Today I tried the following combination:

  • Ubuntu 22.04, OpenJDK 11.0.21, libfaketime 0.9.10-2.1 => The problem does not exist

So to me it seems like the problem is fixed somewhere between versions 0.9.7-3ubuntu1 and 0.9.10-2.1. Unfortunately, 0.9.10-2.1 causes performance issues in combination with OpenJDK 11.0.21 (see issue https://github.com/wolfcw/libfaketime/issues/425), so we still cannot use this version in our setup.

eriknellessen avatar Dec 13 '23 09:12 eriknellessen