Skip to content
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

8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination #7319

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Feb 2, 2022

The loop exit condition of the test method:

if (i == stop) {
break;
}

requires insertion of a loop limit predicate when the loop is turned
into a counted loop. stop is a LoadI. Next:

array[stop - i + j] = 0;

is transformed to:

array[stop - i] = 0;

and the range check for that array access becomes candidate for
predication in a subsequent loop opts pass. stop has control just
above the loop limit check when that happens (because it is assigned
control as late as possible). But the loop predicate for the bound
check needs to be above the loop limit check and that causes the
assert failure.

There's already logic in PhaseIdealLoop::build_loop_late_post_work()
to assign control to nodes above predicates so this sort of issues
doesn't occur. But it only applies to node initially on the entry
projection right above the loop head. The fix I propose is to remove
that restriction.

That logic was added by JDK-8203197 and looking back at this change I
noticed I replaced some existing logic with the current logic but,
while the 2 overlap, the current logic is not guaranteed to always
cover some cases handled by the old logic. So I resurrected that old
logic here.

Finally, when running tests, I hit failures because Opaque nodes for
skeleton predicates can now end up above a predicate that is split
thru phi. That causes the Opaque nodes to be split up and breaks
pattern matching. I'm actually not sure this issue is specific to the
change here so I think it's best to treat it as a general issue and
fix it by cloning the chain of nodes that lead to the Opaque node
down.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7319/head:pull/7319
$ git checkout pull/7319

Update a local copy of the PR:
$ git checkout pull/7319
$ git pull https://git.openjdk.java.net/jdk pull/7319/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7319

View PR using the GUI difftool:
$ git pr show -t 7319

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7319.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 2, 2022

👋 Welcome back roland! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 2, 2022
@openjdk
Copy link

openjdk bot commented Feb 2, 2022

@rwestrel The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Feb 2, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 2, 2022

Webrevs

@TobiHartmann
Copy link
Member

I executed some testing and hit the following failure with the serviceability/sa/ClhsdbCDS* tests (-XX:+UseParallelGC -XX:+UseNUMA:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fc8d7407dcf, pid=18320, tid=18366
#
# JRE version: Java(TM) SE Runtime Environment (19.0) (fastdebug build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, parallel gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x135adcf]  PhaseIdealLoop::get_ctrl(Node*)+0x4f

Current CompileTask:
C2:   1131  710       4       sun.jvm.hotspot.oops.Symbol::asByteArray (34 bytes)

Stack: [0x00007fc8aacee000,0x00007fc8aadef000],  sp=0x00007fc8aade8650,  free space=1001k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x135adcf]  PhaseIdealLoop::get_ctrl(Node*)+0x4f
V  [libjvm.so+0x17ed176]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0x2f6
V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
V  [libjvm.so+0x17f26ed]  PhaseIdealLoop::do_split_if(Node*, RegionNode**, RegionNode**)+0x77d
V  [libjvm.so+0x13b2651]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x201
V  [libjvm.so+0x13a482b]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x12fb
V  [libjvm.so+0xa9c88a]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x28a
V  [libjvm.so+0xa99055]  Compile::Optimize()+0x1035
V  [libjvm.so+0xa9b295]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1575
V  [libjvm.so+0x8b1d99]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x669
V  [libjvm.so+0xaab178]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc88
V  [libjvm.so+0xaabf58]  CompileBroker::compiler_thread_loop()+0x668
V  [libjvm.so+0x193711a]  JavaThread::thread_main_inner()+0x25a
V  [libjvm.so+0x193f460]  Thread::call_run()+0x100
V  [libjvm.so+0x1621fb4]  thread_native_entry(Thread*)+0x104
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8c892ad8b, pid=232, tid=41068
#
# JRE version: Java(TM) SE Runtime Environment (19.0) (fastdebug build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# V  [jvm.dll+0xcbad8b]  PhaseIdealLoop::split_up+0x203b

Current CompileTask:
C2:   1167  562       4       sun.jvm.hotspot.debugger.DebuggerBase::readCInteger (295 bytes)

Stack: [0x000000d711500000,0x000000d711600000],  sp=0x000000d7115f9f70,  free space=999k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0xcbad8b]  PhaseIdealLoop::split_up+0x203b  (split_if.cpp:271)
V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
V  [jvm.dll+0xcb6776]  PhaseIdealLoop::do_split_if+0x346  (split_if.cpp:498)
V  [jvm.dll+0xa5f851]  PhaseIdealLoop::split_if_with_blocks+0x1a1  (loopopts.cpp:1812)
V  [jvm.dll+0xa32ec8]  PhaseIdealLoop::build_and_optimize+0xff8  (loopnode.cpp:4366)
V  [jvm.dll+0x4f3d45]  Compile::Optimize+0x1145  (compile.cpp:2266)
V  [jvm.dll+0x4f0b87]  Compile::Compile+0x14b7  (compile.cpp:810)
V  [jvm.dll+0x4138a5]  C2Compiler::compile_method+0x145  (c2compiler.cpp:115)
V  [jvm.dll+0x50a216]  CompileBroker::invoke_compiler_on_method+0x756  (compileBroker.cpp:2293)
V  [jvm.dll+0x507a06]  CompileBroker::compiler_thread_loop+0x276  (compileBroker.cpp:1967)
V  [jvm.dll+0xd8d317]  JavaThread::thread_main_inner+0x297  (thread.cpp:1296)
V  [jvm.dll+0xd82e64]  Thread::call_run+0x1b4  (thread.cpp:361)
V  [jvm.dll+0xbcb449]  thread_native_entry+0xb9  (os_windows.cpp:544)
C  [ucrtbase.dll+0x1fb80]  _o__realloc_base+0x60
C  [KERNEL32.DLL+0x84d4]  BaseThreadInitThunk+0x14
C  [ntdll.dll+0x51791]  RtlUserThreadStart+0x21

And with tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java on macosx-aarch64:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x000000010295de98, pid=78752, tid=23555
#
# JRE version: Java(TM) SE Runtime Environment (19.0) (build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# V  [libjvm.dylib+0x89de98]  _ZN14PhaseIdealLoop11do_split_ifEP4NodePP10RegionNodeS4_+0x650

Current CompileTask:
C2: 104626 23310       4       java.net.URI$Parser::parseHierarchical (178 bytes)

Stack: [0x00000001709bc000,0x0000000170bbf000],  sp=0x0000000170bbaad0,  free space=2042k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.dylib+0x89de98]  _ZN14PhaseIdealLoop11do_split_ifEP4NodePP10RegionNodeS4_+0x650
V  [libjvm.dylib+0x70df7c]  _ZN14PhaseIdealLoop20split_if_with_blocksER9VectorSetR10Node_Stack+0x11c
V  [libjvm.dylib+0x700ec0]  _ZN14PhaseIdealLoop18build_and_optimizeE12LoopOptsMode+0x838
V  [libjvm.dylib+0x2ca9c4]  _ZN14PhaseIdealLoop8optimizeER12PhaseIterGVN12LoopOptsMode+0x108
V  [libjvm.dylib+0x2cac24]  _ZN7Compile14optimize_loopsER12PhaseIterGVN12LoopOptsMode+0xb0
V  [libjvm.dylib+0x2c7734]  _ZN7Compile8OptimizeEv+0xef4
V  [libjvm.dylib+0x2c59fc]  _ZN7CompileC2EP5ciEnvP8ciMethodi7OptionsP12DirectiveSet+0xaa0
V  [libjvm.dylib+0x23438c]  _ZN10C2Compiler14compile_methodEP5ciEnvP8ciMethodibP12DirectiveSet+0x134
V  [libjvm.dylib+0x2d67e4]  _ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask+0x3d4
V  [libjvm.dylib+0x2d6378]  _ZN13CompileBroker20compiler_thread_loopEv+0x440
V  [libjvm.dylib+0x93bea8]  _ZN10JavaThread17thread_main_innerEv+0xa0
V  [libjvm.dylib+0x93a908]  _ZN6Thread8call_runEv+0xe0
V  [libjvm.dylib+0x7f19e8]  _ZL19thread_native_entryP6Thread+0x158
C  [libsystem_pthread.dylib+0x7240]  _pthread_start+0x94


@rwestrel
Copy link
Contributor Author

rwestrel commented Feb 9, 2022

@TobiHartmann thanks for running testing. I reproduced one of them (thanks for helping with that too) and fixed it. Would you mind running testing again?

@TobiHartmann
Copy link
Member

Sure, I'll re-run testing and report back.

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests passed and the fix looks reasonable to me.

@openjdk
Copy link

openjdk bot commented Feb 11, 2022

@rwestrel This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination

Reviewed-by: thartmann, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 44 new commits pushed to the master branch:

  • 0786ddb: 8281535: Create a regression test for JDK-4670051
  • c5ff6e4: 8223077: module path support for dynamic CDS archive
  • 8886839: 8281622: JFR: Improve documentation of jdk.jfr.Relational
  • e75e8cd: 8279997: check_for_dynamic_dump should not exit vm
  • e73ee0c: 8281259: MutableBigInteger subtraction could be simplified
  • f399ae5: 8202836: [macosx] test java/awt/Graphics/TextAAHintsTest.java fails
  • 4ff5824: 8281100: Spurious "variable might not have been initialized" with sealed class switch
  • d254cf2: 8281638: jfr/event/allocation tests fail with release VMs after JDK-8281318 due to lack of -XX:+UnlockDiagnosticVMOptions
  • 4d64076: 8047749: javadoc for getPathBounds() in TreeUI and BasicTreeUI is incorrect
  • 90939cb: 8281626: NonblockingQueue should use nullptr
  • ... and 34 more: https://git.openjdk.java.net/jdk/compare/380378c551b4243ef72d868571f725b390e12124...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 11, 2022
new_ctrl = c;
}
least = new_ctrl;
}
// Try not to place code on a loop entry projection
// which can inhibit range check elimination.
if (least != early) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same check as new above - you can combine these scopes.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch my previous comment. least value could be updated in new code so we need second check.

@rwestrel
Copy link
Contributor Author

Thanks @TobiHartmann and @vnkozlov for the reviews.

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 14, 2022

Going to push as commit 1ef45c5.
Since your change was applied there have been 55 commits pushed to the master branch:

  • 483d4b9: 8281505: Add CompileCommand PrintIdealPhase
  • adbe066: 8239927: Product variable PrefetchFieldsAhead is unused and should be removed
  • eff5daf: 8274939: Incorrect size of the pixel storage is used by the robot on macOS
  • 8acfbc2: 8281675: VMDeprecatedOptions test fails after JDK-8278423
  • 67077a0: 8278423: ExtendedDTraceProbes should be deprecated
  • 58dae60: 8274524: SSLSocket.close() hangs if it is called during the ssl handshake
  • aa918a6: 8281033: Improve ImageCheckboxTest to test all available LaF
  • 6fdfe04: 8281674: tools/javac/annotations/typeAnnotations/classfile/AnonymousExtendsTest.java fails with AssertionError
  • c3179a8: 8281462: Annotation toString output for enum not reusable for source input
  • 4032fe7: 8281238: TYPE_USE annotations not printed in correct position in toString output
  • ... and 45 more: https://git.openjdk.java.net/jdk/compare/380378c551b4243ef72d868571f725b390e12124...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 14, 2022
@openjdk openjdk bot closed this Feb 14, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 14, 2022
@openjdk
Copy link

openjdk bot commented Feb 14, 2022

@rwestrel Pushed as commit 1ef45c5.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@DamonFool
Copy link
Member

Regression: https://bugs.openjdk.java.net/browse/JDK-8281811
Please have a look. @rwestrel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
4 participants