eclipse / omr

Eclipse OMR™ Cross platform components for building reliable, high performance language runtimes
http://www.eclipse.org/omr
Other
939 stars 394 forks source link

JitBuilder recurses infinitely when it can't find a function #3655

Open rwy7 opened 5 years ago

rwy7 commented 5 years ago

Admittedly, this is invalid code, but I wouldn't expect it to crash this way. When trying to call a function that hasn't been defined (via DefineFunction), JitBuilder overflows the stack trying to find it.

Here are a few frames from the start of the the loop:

frame #174214: 0x0000000000019ac9 intbuilder_example`OMR::JitBuilder::MethodBuilder::RequestFunction(this=0x00007ffeefbff688, name=“jit_trace”) at MethodBuilder.cpp:179
frame #174215: 0x00000000000186f7 intbuilder_example`::MethodBuilderCallback_RequestFunction(clientObj=0x00007ffeefbff688, name=“jit_trace”) at MethodBuilder.cpp:53
frame #174216: 0x0000000000019d9e intbuilder_example`OMR::MethodBuilder::RequestFunction(this=0x0000000000f01540, name=“jit_trace”) at OMRMethodBuilder.hpp:155
frame #174217: 0x0000000000019ac9 intbuilder_example`OMR::JitBuilder::MethodBuilder::RequestFunction(this=0x00007ffeefbff688, name=“jit_trace”) at MethodBuilder.cpp:179
frame #174218: 0x00000000000186f7 intbuilder_example`::MethodBuilderCallback_RequestFunction(clientObj=0x00007ffeefbff688, name=“jit_trace”) at MethodBuilder.cpp:53
frame #174219: 0x0000000000019d9e intbuilder_example`OMR::MethodBuilder::RequestFunction(this=0x0000000000f01540, name=“jit_trace”) at OMRMethodBuilder.hpp:155
frame #174220: 0x0000000000155305 intbuilder_example`OMR::IlBuilder::Call(this=0x0000000000f01540, functionName=“jit_trace”, numArgs=2, argValues=0x0000000003000c40) at OMRIlBuilder.cpp:2031
frame #174221: 0x0000000000012e2c intbuilder_example`OMR::JitBuilder::IlBuilder::Call(this=0x00007ffeefbff688, name=“jit_trace”, numArgs=2, arguments=0x0000000003000c30) at IlBuilder.cpp:588
frame #174222: 0x0000000000013151 intbuilder_example`OMR::JitBuilder::IlBuilder::Call(this=0x00007ffeefbff688, name=“jit_trace”, numArgs=2) at IlBuilder.cpp:600
Leonardo2718 commented 5 years ago

Looking at this quickly, I think the problem is that OMR::MethodBuilder::RequestFunction() https://github.com/eclipse/omr/blob/36fdb14b9f516b793932bb9751dc821735ac170e/compiler/ilgen/OMRMethodBuilder.hpp#L152-L158

does not follow the pattern for callbacks through the client API: https://github.com/eclipse/omr/tree/master/jitbuilder/apigen#high-level-design .