-
Bug
-
Resolution: Won't Fix
-
P4
-
11, 13, 14
-
generic
-
windows
If Control Flow Guard is enabled for attach.dll (i.e. option /guard:cf is used)
then any attempt to attach results in a segmentation fault on the side of the
target jvm. On the side of attaching process an error like listed below is triggered:
Exception in thread "main" java.lang.InternalError: Remote thread failed for unknown reason (-1073741819)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.enqueue(Native Method)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:62)
at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:69)
at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:113)
at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:97)
Steps to reproduce:
* build jdk using vs2017 with extra flags:
--with-extra-cflags=â/guard:cf' --with-extra-cxxflags=â/guard:cf' --with-extra-ldflags=â/guard:cfâ
* start target jvm:
./images/jdk/bin/java.exe -jar ./jdk/demo/jfc/Notepad/Notepad.jar
* attach to target jvm with jcmd:
./images/jdk/bin/jcmd.exe <target_jvm_pid> help
Suggested solution is to explicitely disable Control Flow Guard machinery
for jvm_attach_thread_func(), as it is already done for other runtime checks:
--- a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c Tue Jul 30 17:31:29 2019 -0400
+++ b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c Tue Jul 30 22:35:39 2019 -0700
@@ -99,6 +99,7 @@
* generated code to contain relative jumps to check functions which make
* the code position dependent. */
#pragma runtime_checks ("scu", off)
+__declspec(guard(nocf))
DWORD WINAPI jvm_attach_thread_func(DataBlock *pData)
{
HINSTANCE h;
then any attempt to attach results in a segmentation fault on the side of the
target jvm. On the side of attaching process an error like listed below is triggered:
Exception in thread "main" java.lang.InternalError: Remote thread failed for unknown reason (-1073741819)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.enqueue(Native Method)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:62)
at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:69)
at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:113)
at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:97)
Steps to reproduce:
* build jdk using vs2017 with extra flags:
--with-extra-cflags=â/guard:cf' --with-extra-cxxflags=â/guard:cf' --with-extra-ldflags=â/guard:cfâ
* start target jvm:
./images/jdk/bin/java.exe -jar ./jdk/demo/jfc/Notepad/Notepad.jar
* attach to target jvm with jcmd:
./images/jdk/bin/jcmd.exe <target_jvm_pid> help
Suggested solution is to explicitely disable Control Flow Guard machinery
for jvm_attach_thread_func(), as it is already done for other runtime checks:
--- a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c Tue Jul 30 17:31:29 2019 -0400
+++ b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c Tue Jul 30 22:35:39 2019 -0700
@@ -99,6 +99,7 @@
* generated code to contain relative jumps to check functions which make
* the code position dependent. */
#pragma runtime_checks ("scu", off)
+__declspec(guard(nocf))
DWORD WINAPI jvm_attach_thread_func(DataBlock *pData)
{
HINSTANCE h;