-
Notifications
You must be signed in to change notification settings - Fork 937
Test comptask feature
#1293
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
Test comptask feature
#1293
Conversation
498af69 to
ce9b53b
Compare
src/vmStructs.h
Outdated
| if (goodPtr(env)) { | ||
| const char* task = (const char*) SafeAccess::load((void**) (env + _comp_task_offset)); | ||
| if (goodPtr(task)) { | ||
| return (VMMethod*) SafeAccess::load((void**) (task + _comp_method_offset)); |
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.
Why did you change this?
compiledMethod() is called at a known location where all pointers should be valid. If it's not the case, there must be a bug somewhere.
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.
Check this segfault stacktrace: https://github.com/fandreuz/async-profiler/actions/runs/15069387768/job/42361695062#step:16:164
In the same run, I also added some debug print statements:
VMMethod* compiledMethod() {
const char* env = *(const char**) at(_comp_env_offset);
if (env != NULL) {
const char* task = *(const char**) (env + _comp_task_offset);
if (task != NULL) {
+ fprintf(stderr, "env: %p, taks_ptr: %p, task_offset: %d, method_ptr: %p, method_offset: %d\n",
+ env, task, _comp_task_offset, task + _comp_method_offset, _comp_method_offset);
return *(VMMethod**) (task + _comp_method_offset);
}
}
return NULL;
}and these are the last few lines before the segfault:
env: 0x7f6014cf9a10, taks_ptr: 0x7f60310208d0, task_offset: 112, method_ptr: 0x7f60310208e0, method_offset: 16
env: 0x7f6014cf9a10, taks_ptr: 0x7f60310208d0, task_offset: 112, method_ptr: 0x7f60310208e0, method_offset: 16
env: 0x7f6014cf9a10, taks_ptr: 0x7f60310208d0, task_offset: 112, method_ptr: 0x7f60310208e0, method_offset: 16
env: 0x7f6014cf9a10, taks_ptr: 0x1, task_offset: 112, method_ptr: 0x11, method_offset: 16
It seems that the dereferenced pointer to CompileTask points to some random location. In a different run, I also got a valid task_ptr and an invalid method_ptr.
Do we have any strong guarantee about the memory we're reading? I guess we don't, the JVM seems to be free to reuse it however it likes. My theory here is that the CompileTask completed successfully, and we're just getting access to some memory which has been recycled.
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.
OK, so your test found a real bug, and that's actually a good news.
The reason is, CompilerThread::_env is initialized inside invoke_compiler_on_method. This means, it's not always safe to access _env inside invoke_compiler_on_method, we should check the presence of another frame like compile_method.
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.
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.
Fixed
|
@apangin all comments have been addressed |
Description
Add a test to check that the method being compiled appears correctly in the profile when
features=comptaskis used.Related issues
Will be useful to test changes related to #1260
Motivation and context
We don't have an integration test for
features=comptaskyet.How has this been tested?
GHA
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.