Remove dangerous memsets that don't survive gcc16 dead store optimization - #24564
Conversation
|
The Clang Format Check, I would fix it if I knew how to get the information from it. And there was no commit hook warning me about anything. Is there some |
|
The OMR PR related to this one is eclipse-openj9/openj9-omr#286 |
The Clang Format Check job prints out a diff that you can apply to get the proper formatting. You can find more details on the format here. |
38f2a77 to
86df88e
Compare
I downloaded the .clang-format from the link mentioned in the doc. I ran the command |
|
As for a possibility of build failing with these fixes only, it is normal, the related commit in openj9-omr from eclipse-openj9/openj9-omr#286 is needed. But that commit can land without this PR being integrated if need be, because the current state with the memset hack will still be working with that commit. Just this PR needs the TR_StatsEvents properly initialized. |
It's likely that you need to use the exact Clang Format version as the one used in the Linter job. If you look at the documentation linked above, it should point you to the Dockerfile that the Linter uses, which specifies the version. Clang Format unfortunately changes its output, even across minor versions. At any rate, if you continue to run into issues, applying the diff provided by the format checker job will unblock you. |
I must be dumb, can you point me to the log? |
https://openj9-jenkins.osuosl.org/job/PullRequest-Clang-Format-Check/2942/console |
Thanks, that helped. I fixed it manually instead of chasing the exact version of clang-format :( |
7c03444 to
4530277
Compare
|
Where is this one hanging? Do I need to rebase it? |
|
I would not mind it to be in for the October release. |
|
Btw, the corresponding omr fix went in, so this one should be perfectly buildable with MALLOC_PERTURB_ using recent omr. I did not rebase because I don't know how many reviews it would invalidate, but just say a word... But the rebase done here locally did not have one single conflict. |
|
I hit this discrepancy btw: In RelocationRuntime.hpp:522 (UNCONDITIONAL): In RelocationRuntime.cpp:245 (CONDITIONAL): The #if 1 sucks them unconditionally. What is the right thing to do with them? Which condition is good? RelocationRecord.cpp:3398 calls incNumValidations() unconditionally, incrementing garbage memory |
mpirvu
left a comment
There was a problem hiding this comment.
LGTM.
A few small suggestions:
- Remove stale comment: "// The object is zero-initialized before this method is called" from CompilationThread.cpp line 1279
- Move "_jitConfig = jitConfig;" (line 1282) into the initializer list of CompilationInfo.
- Move "_vmStateOfCrashedThread = 0;" (line 1288) into the initializer list of CompilationInfo
- Move "_crashWasDueToOrphanedConstRefs = false;" (line 1289) into the initializer list of CompilationInfo
- I am in favor of removing that "#if 1" both from RelocationRuntime.hpp and cpp files.
- Please squash all commits into 1.
Paired with OMR commit with the same title
Done. Just remember that the commit in omr openj9 branch with the exactly same title is needed so that this works fine. |
|
jenkins test sanity all jdk25 |
|
The |
|
The JFR test failure is a known issue covered by #24693 |
|
If this gets integrated, what is the probability it could make it for 0.63.0? |
|
I checked yesterday, the omr patch is not strictly necessary, since it only fixes stuff like zeroing *this in constructor and I was finding it quite bad C++ and fixed it. But I run my builds without it and with MALLOC_PERTURB_ the bootcycle builds passed just fine, with gcc 16.2.0, without this patch, they clearly were crashing showing poisoned memory, without the omr patch, they passed. |
|
The other test failures have all been seen before. AIX failed jdk_foreign_0 Exception in thread "" java.lang.IncompatibleClassChangeError and timeout tracked here: #22224 (comment) openjdk on xlinux failed jdk_util_other_1 Tracked here: #24811 openjdk mac failed jdk_lang_0 openjdk windows failed jdk_security4_1 Tracked here: #17749 |
|
Since all test failure have been accounted for, this PR is ready to be merged. |
|
@fridrich pls cherry pick your commit against https://github.com/eclipse-openj9/openj9/tree/v0.63.0-release and create a PR. |
|
|
||
| // An allocation node has been found. Create a new candidate entry. | ||
| // | ||
| Candidate *candidate = new (trStackMemory()) Candidate; |
There was a problem hiding this comment.
I believe the previous new expression was correct; adding parentheses is not appropriate:
Candidate *candidate = new (trStackMemory()) Candidate;There was a problem hiding this comment.
Why? It seems the parentheses will cause zero init of the members which aren't explicitly initialized in the constructor.
There was a problem hiding this comment.
The parentheses call the Candidate constructor in which I took care to properly initialize every member of the struct.
BTW, I really love that idea of MALLOC_PERTURB_ and the fact that SUSE build service builds always setting it to 63, so that we can know immediately from the log whether we read after free or whether we use uninitialized memory. Something like this in the CI workflow could be good. But yes, that would require to build bootcycle-images so that one actually tests the currently built virtual machine.
|
Thank you, @fridrich. It's refreshing to see this sort of improvement. |
Glad to help. First approach was memory barrier, but that one is not portable if we don't use C++11. But this is cleaner and more C++ like :) |
|
The project failed to build properly because GCC 16 optimized out a memory operation during the
TR::CompilationInfoconstruction (memsetinsidecreateCompilationInfo). As a band-aid, I put a memory barrier (__asm__("" : : : "memory")) between thememsetand the subsequentnewcalls. Just that in C++98, there is no portable way to put a memory barrier, so that was not a real solution for this problem.Nevertheless, I saw a comment that was advising the proper solution. The goal was to remove the workaround and fix the C++ class initializations properly so that the memory is fully zero-initialized safely without
memsethacks on thethispointer or immediately before placement new, ensuring it doesn't crash when running underMALLOC_PERTURB_=63.And since this is exactly the kind of thing, where code assist agents are useful, I was doing this using Gemini, for the full disclosure. Still building myself with the
MALLOC_PERTURB_and iterating over the crashes until a cleanbootcycle-imagesbuild was not successful.After fixing the current crash with gcc16 optimization, I scanned the code for similar constructs and found one potential ticking bomb in
runtime/compiler/optimizer/NewInitialization.cpp. Since the fix was trivial, I added that one too.This pull request will need a similar pull request in OMR that I will create after this one. The part is to initialize properly the
TR_StatsEventsincompiler/infra/Statistics.hpp.