wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.62k stars 319 forks source link

Java processes with libfaketime do not stop when getting SIGTERM #447

Open eriknellessen opened 7 months ago

eriknellessen commented 7 months ago

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):

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.

wolfcw commented 7 months ago

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?

eriknellessen commented 7 months ago

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:

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.