-
Notifications
You must be signed in to change notification settings - Fork 754
Add check for throwDefaultConflict J9Method #21336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add check for throwDefaultConflict J9Method #21336
Conversation
425f427
to
681ad93
Compare
runtime/vm/BytecodeInterpreter.hpp
Outdated
#define nullCheck_j9bj(j9obj, fromJIT, dec_sp) \ | ||
do { \ | ||
if (J9_UNEXPECTED(NULL == j9obj)) { \ | ||
if (fromJIT) { \ | ||
_sp -= dec_sp; \ | ||
buildJITResolveFrame(REGISTER_ARGS); \ | ||
} \ | ||
return THROW_NPE; \ | ||
} \ | ||
} while (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Instead of a
define
macro, an inlined function should be added for this code snippet. - If the macro is retained, the name's formatting should be fixed. It should be all caps (see
#define RECORD_BYTECODE_PAIR(number) \
for reference).
runtime/vm/BytecodeInterpreter.hpp
Outdated
void *const jitReturnAddress = VM_JITInterface::fetchJITReturnAddress(_currentThread, _sp); | ||
J9ROMMethod *const romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(_sendMethod); | ||
void *const exitPoint = j2iReturnPoint(J9ROMMETHOD_SIGNATURE(romMethod)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file consistently follows void* const
formatting throughout. So, we shouldn't modify it to void *const
over here.
I have provided feedback on this PR but am unsure about the correct guidelines for |
1976ac1
to
11e99cc
Compare
thanks for the review @babsingh . I've made the changes you suggested. If you or @gacholio could take a provide more info about what |
11e99cc
to
58a22ad
Compare
I will look at this in detail shortly - my feeling is that this should just work. Is the default conflict method marked as native (which affects the JIT transition)? |
At the moment the only definition for this method is However this will be changing in another PR: the |
I think I understand the issue now - the conflict method is too fake - it's not native, but has no bytecodes. I suspect if we turn this method into an INL native and possibly mark it as never translate in the count field. throwForDefaultConflict already builds a stack frame, so it may be enough just to change the definition of the fake method. @babsingh @fengxue-IS What do you think? |
I'm not quite sure how we get to the default conflict method, so it may not be practical to mark it native (which is a property of the ROM method). Perhaps we can use a new code in the count field to indicate that this method should take the native path when transitioning into the interpreter. Any negative value in count will prevent translation. |
I see there's already checks for the default conflict method - for now, if we just make the transition code take the native path when this is detected (and update the count to never translate) that may be sufficient. |
this works on Z but will not work on x86 since it has JitDispatchJ9Method enabled, which causes an This doesn't happen on Z since the call to the fake method goes through the INL method |
What does |
0781756
to
93634d9
Compare
93634d9
to
6c2d620
Compare
It may be useful or necessary to make the conflict send target use the INL native convention (currently it build a generic method frame). |
3f9d86a
to
f97a110
Compare
f97a110
to
f998f9a
Compare
f998f9a
to
72a0da9
Compare
Checks that the J9Method being invoked is not the special J9Method vm->initialMethods.throwDefaultConflict. This fixes a segfault that was happening when trying to load a bytecodes field containing 0x0 Fixes: eclipse-openj9#20677 Signed-off-by: Matthew Hall <matthew.hall3@outlook.com>
72a0da9
to
5ec2adb
Compare
@gacholio can I get another review please? All my perosnal tests are passing, both on jenkins and locally (since this case almost never happens on Jenkins). Most of the jobs that show as failed are false - no actual fails show in the results. The few real fails unrelated |
Apologies, I've been out sick all week. There should be no need for a resolve frame - the native transition will take care of the stack. |
@@ -648,8 +652,13 @@ class INTERPRETER_CLASS | |||
#endif /* J9SW_NEEDS_JIT_2_INTERP_CALLEE_ARG_POP */ | |||
/* Set the flag indicating that the caller was the JIT */ | |||
_currentThread->jitStackFrameFlags = J9_SSF_JIT_NATIVE_TRANSITION_FRAME; | |||
/* If a stop request has been posted, handle it instead of running the native */ | |||
if (isMethodDefaultConflictForMethodHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this necessary - see the suggested change to the throwing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is building a JIT Resolve Frame is not necessary? Without it, even with the suggestions below, the wrong method is used to throw the error:
In gdb we get
Thread 2 "main" received signal SIGSEGV, Segmentation fault.
dropPendingSendPushes (currentThread=0x17000) at /root/jdks/openj9-openjdk-jdk21/openj9/runtime/vm/drophelp.c:58
58 UDATA slotCount = J9_ARG_COUNT_FROM_ROM_METHOD(romMethod) + J9_TEMP_COUNT_FROM_ROM_METHOD(romMethod);
=> 0x00007ffff7a6f138 <dropPendingSendPushes+104>: 0f b6 42 fd movzbl -0x3(%rdx),%eax
(gdb) print method
$1 = (J9Method *) 0x7fff7ac0015c
(gdb) gcore
warning: target file /proc/1136059/cmdline contained unexpected null characters
warning: Memory read failed for corefile section, 4096 bytes at 0xffffffffff600000.
Saved corefile core.1136059
(gdb) print method->bytecodes
$2 = (U_8 *) 0x9eb00685297eb <error: Cannot access memory at address 0x9eb00685297eb>
(gdb)
which is not the fake method, and has inaccessible bytecodes. The method we get at that address is
(kca) j9m 0x7fff7ac0015c
J9Method for JIT Method: {java/lang/invoke/LambdaForm$DMH/0x00000000f0b76c20.invokeSpecialIFC}
Method {ClassPath/Name.MethodName}: {java/lang/invoke/LambdaForm$DMH/0x00000000f0b76c20.invokeSpecialIFC}
which is the Lambda Form used to call the (in this case fake) method.
NullPointerExceptions within the various linkTo* methods for LambdaForms build a JIT resolve frame so it may be necessary here too.
@@ -9915,12 +9925,10 @@ class INTERPRETER_CLASS | |||
VMINLINE VM_BytecodeAction | |||
throwDefaultConflictForMemberName(REGISTER_ARGS_LIST) | |||
{ | |||
/* Load the conflicting method and error message from this special target */ | |||
buildGenericSpecialStackFrame(REGISTER_ARGS, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this in but use the jit frame flags:
buildGenericSpecialStackFrame(REGISTER_ARGS, jitStackFrameFlags(REGISTER_ARGS, 0));
updateVMStruct(REGISTER_ARGS); | ||
prepareForExceptionThrow(_currentThread); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is needed given the special stack frame build above.
You don't appear to have made any changes since the last review request. |
Part of fix for #20677
Checks for special initial J9Method
throwDefaultConflict
inlinkToStaticSpecial()
, and throws defaultConflict error (IncompatibleClassChangeError
) accordingly.throwDefaultConflict
:J9Method::extra
field was changed from0
toJ9_JIT_NEVER_TRANSLATE
. This fixes a crash in the JITed code where we assumed the method was compiled (since the last bit was 0). The case for when we try an invoke the default conflict method from the JIT is now handled in the vm BytecodeInterpreter.j2iTransition
and handles error on same path a Native methodsdefaultConflictForMemberName
error setup to be same as other Java level errors like NullPointer, WrongMethodType, ArrayIndex, etc.