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

Eclipse IDE crashes with -Xverify:none #4904

Closed
dcendents opened this issue Feb 27, 2019 · 53 comments
Closed

Eclipse IDE crashes with -Xverify:none #4904

dcendents opened this issue Feb 27, 2019 · 53 comments

Comments

@dcendents
Copy link

I recently learned about OpenJ9 and I wanted to start using it. However I experienced systematic crashes when doing a full clean/build of my projects in eclipse.

I eventually narrowed it down to the -Xverify:none switch, which I can see is not supported by OpenJ9: https://www.eclipse.org/openj9/docs/xverify/

Should OpenJ9 ignore it if this is harmful?
I'm sure a lot of people running eclipse with hotspot have that switch on, it's been documented for years as an option to set to speed up eclipse.

As a reference, this is my custom eclipse switches that I had with hotspot:

-Xmn512m
-Xss2m
-Xverify:none
-Xms1024m
-Xmx3072m
-XX:+UseG1GC
-XX:+UseStringDeduplication

This is what I now use with OpenJ9 and seems to be stable:

-Xss2m
-Xms1024m
-Xmx3072m
-Xtune:virtualized
-Xshareclasses:cacheDir=C:\dev\eclipses\shared-classes
@fjeremic
Copy link
Contributor

I'm sure a lot of people running eclipse with hotspot have that switch on, it's been documented for years as an option to set to speed up eclipse.

Do you have a reference for this? We can work with the Eclipse team to remove this recommendation. OpenJ9 JVM makes certain assumptions on the basis that the bytecode verifier ran. This is why at a high level -Xverify:none is an unsupported configuration.

Someone more familiar on the VM side of things can give more details.

@DanHeidinga
Copy link
Member

@dcendents if you remove -Xverify:none, does the JVM throw java.lang.VerifyError or similar exceptions?

I wouldn't expect to see a crash unless there was unverifiable classfiles being loaded - in which case, all bets are off.

@dcendents
Copy link
Author

@fjeremic It is not a recommendation by eclipse, but something you will find has been recommended by the community multiple times over the years. A simple google search on how to speed up eclipse will return such posts:

https://stackoverflow.com/questions/316265/how-can-you-speed-up-eclipse
http://www.nicolasbize.com/blog/7-tips-to-speed-up-eclipse/

And since this has never caused me any problem with hotspot, I've always added de-facto it to my eclipse.ini file (until now)

@DanHeidinga I've never had a java.lang.VerifyError when the option is not set, either with hotspot or openj9, or anyone else I work with.

@ChengJin01
Copy link

ChengJin01 commented Feb 27, 2019

@dcendents , was there any dump file (.dmp/.trc ,e.g) generated from the crash with -verify:none
specified in eclipse.ini (I assume this is not a VM option for your project in the workspace) ? It would be quite helpful for us to get started from there; otherwise, we might need to a simple way to reproduce the crash on our side.

@dcendents
Copy link
Author

@ChengJin01 I have uploaded the dump files on my google drive and sent you an email with the link.

@ChengJin01
Copy link

Many thanks @dcendents , already received the e-mail and will check the dumps.

@ChengJin01
Copy link

ChengJin01 commented Mar 4, 2019

  1. the java core shows it repeatedly looped from org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass to java/lang/ClassLoader.defineClassImpl, which led to crash and the system dump inevitably got screwed up as as result.
1XMCURTHDINFO  Current thread
3XMTHREADINFO      "Worker-2: Building Workspace" J9VMThread:0x0000000003088500, omrthread_t:0x0000000012DA7A40, java/lang/Thread:0x0000000749C7AC78, state:R, prio=5
3XMJAVALTHREAD            (java/lang/Thread getId:0x27, isDaemon:false)
3XMTHREADINFO1            (native thread ID:0x1884, native priority:0x5, native policy:UNKNOWN, vmstate:R, vm thread flags:0x00000020)
3XMCPUTIME               CPU usage total: 136.328125000 secs, user: 94.078125000 secs, system: 42.250000000 secs, current category="Application"
3XMHEAPALLOC             Heap bytes allocated since last GC cycle=207685632 (0xC610800)
3XMTHREADINFO3           Java callstack:
4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379(Compiled Code))
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086(Compiled Code))
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401(Compiled Code))
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007EB0AFC90, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239(Compiled Code))

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379(Compiled Code))
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086(Compiled Code))
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401(Compiled Code))
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007EB089520, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239(Compiled Code))

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379(Compiled Code))
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086(Compiled Code))
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401(Compiled Code))
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007EB07A4B8, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239(Compiled Code))

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379(Compiled Code))
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89(Compiled Code))
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086(Compiled Code))
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401(Compiled Code))
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007EB058FF0, entry count: 1)

4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247(Compiled Code))
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239(Compiled Code))

4XESTACKTRACE                at java/lang/Class.getDeclaredFieldsImpl(Native Method)
4XESTACKTRACE                at java/lang/Class.getDeclaredFields(Class.java:867(Compiled Code))
...
  1. DDR shows all these stacks of the current thread in the loop happened in JIT:
    java_stack.txt
<3088500> *** BEGIN STACK WALK, flags = 00400001 walkThread = 0x0000000003088500 ***
<3088500>       ITERATE_O_SLOTS
<3088500>       RECORD_BYTECODE_PC_OFFSET
<3088500> Initial values: walkSP = 0x00000000041098F0, PC = 0x0000000000000006, literals = 0x0000000000000008, A0 = 0x0000000004109990, j2iFrame = 0x0000000004109C00, ELS = 0x0000000017FED7E0, decomp = 0x0000000000000000
<3088500> JIT JNI call-out frame: bp = 0x0000000004109918, sp = 0x00000000041098F0, pc = 0x0000000000000006, cp = 0x0000000002A0FD80, arg0EA = 0x0000000004109990, flags = 0x0000000020000000
<3088500>       Method: java/lang/ClassLoader.defineClassImpl(Ljava/lang/String;[BIILjava/lang/Object;)Ljava/lang/Class; !j9method 0x0000000002A11290
<3088500>       Object pushes starting at 0x00000000041098F0 for 1 slots
<3088500>               Push[0x00000000041098F0] = 0x00000007EAEA5F10
<3088500> JIT frame: bp = 0x0000000004109988, pc = 0x000000004EE1C014, unwindSP = 0x0000000004109920, cp = 0x0000000002A0FD80, arg0EA = 0x00000000041099B8, jitInfo = 0x00000000111192E8
<3088500>       Method: java/lang/ClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; !j9method 0x0000000002A111D0
<3088500>       Bytecode index = 102, inlineDepth = 0, PC offset = 0x00000000000001AC
<3088500>       stackMap=0x0000000011119428, slots=I16(0x0006) parmBaseOffset=I16(0x0008), parmSlots=U16(0x0006), localBaseOffset=I16(0xFFE0)
<3088500>       Described JIT args starting at 0x0000000004109990 for U16(0x0006) slots
<3088500>               O-Slot: : a5[0x0000000004109990] = 0x00000007EAEA5F10
<3088500>               I-Slot: : a4[0x0000000004109998] = 0x0000000000005F45
...

So the problem should have something to do with class loading & JIT.

@dcendents , could you help to check whether it still crashes with -Xint specified ?
If so, the problem might come from VM; otherwise it needs the JIT team to get involved in the further investigation.

@fjeremic
Copy link
Contributor

fjeremic commented Mar 4, 2019

Judging from the fact that the issue happen on Eclipse and the java_stack.txt showing "jit_rbx" I'll assume this is x86 related. In which case @andrewcraik FYI the above.

Edit:

Adding some tags to keep this on the radar. If determined failing with -Xint we can remove.

@andrewcraik
Copy link
Contributor

andrewcraik commented Mar 4, 2019

Interesting - I'll wait for the result with -Xint to see if it seems to be JIT related. The loadClass method above seems to have a try catch which could end up circular if the wrong calls were made or some kind of circularity made its way into the load strategy (was looking at https://github.com/sonatype/plexus-classworlds/blob/e869ac904400f0a966e64af7e28709ef2dd5dd3f/src/main/java/org/codehaus/plexus/classworlds/realm/ClassRealm.java#L260). Another experiment would be to use -Xjit:dontInline={org/codehaus/plexhus/classworlds/realm/ClassReam.unschronizedLoadClass(*},exclude={org/codehaus/plexhus/classworlds/realm/ClassReam.unschronizedLoadClass(*} which would disable the optimization of the most likely point for the loop to see if that is related.

@dcendents
Copy link
Author

I've just tested again with the -Xint flag and it did crash again.

I've also tested with -Xjit:dontInline={org/codehaus/plexhus/classworlds/realm/ClassReam.unschronizedLoadClass(*},exclude={org/codehaus/plexhus/classworlds/realm/ClassReam.unschronizedLoadClass(*} and it also crashed.

I did not try with both flags at the same time.

I cannot upload everything in my google drive at the same time. Let me know if you need the dump files and I'll send them to you on Monday, one set at a time.

Have a good weekend.

@pshipton
Copy link
Member

pshipton commented Mar 8, 2019

Note the dump files should compress nicely, if you aren't already doing that.

@dcendents
Copy link
Author

@pshipton You are right they compress nicely, I should have thought about it!

I've sent a link to @ChengJin01 @andrewcraik and @pshipton
@fjeremic your profile page does not have an email listed, but I'm sure one of the guys can forward you the link if you are interested.

Let me know if you want me to try other options or some newer builds.

@pshipton
Copy link
Member

When I try to download I get Access to doc-10-90-docs.googleusercontent.com was denied

@andrewcraik
Copy link
Contributor

@pshipton while there might be a bug in the JIT as well, the crash with Xint might be easier to diagnose so could you let me know what you find from the Xint run? We can then consider if there might be a similar/related issue in the JIT that we need to fix too.

@dcendents
Copy link
Author

@pshipton it works for me (using the link in the email, unsigned gdrive user in firefox). There was an error saying the file is too big to be scanned but it is possible to download the file.

Is is possible your corporate proxy is blocking the google drive site?

@pshipton
Copy link
Member

Thanks, I managed to download it.

@pshipton
Copy link
Member

pshipton commented Mar 11, 2019

It seems to be crashing in a call to memcmp().

@ChengJin01
Copy link

ChengJin01 commented Mar 11, 2019

The java core with -Xint shows exactly the same result as previously, which looks like there is a loop with class loading in this case:

1XMCURTHDINFO  Current thread
3XMTHREADINFO      "Worker-0: Building Workspace" J9VMThread:0x0000000002CD1900, omrthread_t:0x0000000011D0B9D0, java/lang/Thread:0x0000000748224D98, state:R, prio=5
3XMJAVALTHREAD            (java/lang/Thread getId:0x17, isDaemon:false)
3XMTHREADINFO1            (native thread ID:0x37DC, native priority:0x5, native policy:UNKNOWN, vmstate:R, vm thread flags:0x00000020)
3XMCPUTIME               CPU usage total: 533.484375000 secs, user: 509.484375000 secs, system: 24.000000000 secs, current category="Application"
3XMHEAPALLOC             Heap bytes allocated since last GC cycle=4687744 (0x478780)
3XMTHREADINFO3           Java callstack:
4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379)
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142)
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682)
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89)
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086)
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401)
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007F5454938, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239)

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379)
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142)
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682)
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89)
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086)
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401)
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007F542C560, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239)

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379)
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142)
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682)
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89)
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086)
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401)
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007F541D698, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239)

4XESTACKTRACE                at java/lang/ClassLoader.defineClassImpl(Native Method)
4XESTACKTRACE                at java/lang/ClassLoader.defineClass(ClassLoader.java:379)
4XESTACKTRACE                at java/security/SecureClassLoader.defineClass(SecureClassLoader.java:142)
4XESTACKTRACE                at java/net/URLClassLoader.defineClass(URLClassLoader.java:682)
4XESTACKTRACE                at java/net/URLClassLoader.access$400(URLClassLoader.java:89)
4XESTACKTRACE                at java/net/URLClassLoader$ClassFinder.run(URLClassLoader.java:1086)
4XESTACKTRACE                at java/security/AccessController.doPrivileged(AccessController.java:739)
4XESTACKTRACE                at java/net/URLClassLoader.findClass(URLClassLoader.java:589)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClassFromSelf(ClassRealm.java:401)
5XESTACKTRACE                   (entered lock: java/lang/Object@0x00000007F53FA8C8, entry count: 1)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:247)
4XESTACKTRACE                at org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(ClassRealm.java:239)

4XESTACKTRACE                at java/lang/Class.getDeclaredFieldsImpl(Native Method)
4XESTACKTRACE                at java/lang/Class.getDeclaredFields(Class.java:867)
4XESTACKTRACE                at com/google/inject/spi/InjectionPoint.getInjectionPoints(InjectionPoint.java:675)
4XESTACKTRACE                at com/google/inject/spi/InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:380)
4XESTACKTRACE                at org/eclipse/sisu/wire/DependencyAnalyzer.analyzeImplementation(DependencyAnalyzer.java:224)
4XESTACKTRACE                at org/eclipse/sisu/wire/DependencyAnalyzer.visit(DependencyAnalyzer.java:156)
                             ... ...
3XMTHREADINFO3           Native callstack:
4XENATIVESTACK               memcmp+0x10 (0x000000006A91BDC0 [MSVCR100+0x3bdc0])
4XENATIVESTACK               J9_CreateJavaVM+0x4d1b3 (0x000007FEE92C4823 [j9vm29+0xd4823])
4XENATIVESTACK               J9_CreateJavaVM+0x8e60d (0x000007FEE9305C7D [j9vm29+0x115c7d])
4XENATIVESTACK               J9_CreateJavaVM+0x8ed45 (0x000007FEE93063B5 [j9vm29+0x1163b5])
4XENATIVESTACK               J9_CreateJavaVM+0x4d391 (0x000007FEE92C4A01 [j9vm29+0xd4a01])
4XENATIVESTACK               J9_CreateJavaVM+0x4d77b (0x000007FEE92C4DEB [j9vm29+0xd4deb])
4XENATIVESTACK               J9_CreateJavaVM+0x4daf9 (0x000007FEE92C5169 [j9vm29+0xd5169])

@ChengJin01
Copy link

I double-checked the corresponding system core dumps as follows:

<2cd1900> Bytecode frame: bp = 0x00000000041C6BC8, sp = 0x00000000041C6BB8, pc = 0x00000000156D83C3, cp = 0x0000000003AA90C0, arg0EA = 0x00000000041C6BD8, flags = 0x0000000000000000
<2cd1900>       Method: org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(Ljava/lang/String;)Ljava/lang/Class; !j9method 0x0000000003AA9B88
<2cd1900>       Bytecode index = 3
<2cd1900>       Using local mapper
<2cd1900>       Locals starting at 0x00000000041C6BD8 for 0x0000000000000002 slots
<2cd1900>               I-Slot: a0[0x00000000041C6BD8] = 0x00000007FAC238A0
<2cd1900>               I-Slot: a1[0x00000000041C6BD0] = 0x00000007F54548C0 <-------------------

> j9object  0x00000007F54548C0
J9VMJavaLangString at 0x00000007F54548C0 {

struct J9Class* clazz = !j9class 0x2842B00   // java/lang/String
Object flags = 0x00000000;
[C value = !fj9object 0xeac49ebf (offset=0) (java/lang/String)
I count = 0x0000002D (offset=4) (java/lang/String)
I hashCode = 0xD8CEC9CF (offset=8) (java/lang/String)
"org.codehaus.plexus.archiver.AbstractArchiver"
...
<2cd1900> Bytecode frame: bp = 0x00000000041C6F98, sp = 0x00000000041C6F88, pc = 0x00000000156D83C3, cp = 0x0000000003AA90C0, arg0EA = 0x00000000041C6FA8, flags = 0x0000000000000000
<2cd1900>       Method: org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(Ljava/lang/String;)Ljava/lang/Class; !j9method 0x0000000003AA9B88
<2cd1900>       Bytecode index = 3
<2cd1900>       Using local mapper
<2cd1900>       Locals starting at 0x00000000041C6FA8 for 0x0000000000000002 slots
<2cd1900>               I-Slot: a0[0x00000000041C6FA8] = 0x00000007FAC238A0
<2cd1900>               I-Slot: a1[0x00000000041C6FA0] = 0x00000007F542C4E0  <---------------

> j9object 0x00000007F542C4E0
J9VMJavaLangString at 0x00000007F542C4E0 {

struct J9Class* clazz = !j9class 0x2842B00   // java/lang/String
Object flags = 0x00000000;
[C value = !fj9object 0xeabe51c3 (offset=0) (java/lang/String)
I count = 0x00000034 (offset=4) (java/lang/String)
I hashCode = 0x5FAB0825 (offset=8) (java/lang/String)
"org.codehaus.plexus.archiver.zip.AbstractZipArchiver"
...
<2cd1900> Bytecode frame: bp = 0x00000000041C7368, sp = 0x00000000041C7358, pc = 0x00000000156D83C3, cp = 0x0000000003AA90C0, arg0EA = 0x00000000041C7378, flags = 0x0000000000000000
<2cd1900>       Method: org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(Ljava/lang/String;)Ljava/lang/Class; !j9method 0x0000000003AA9B88
<2cd1900>       Bytecode index = 3
<2cd1900>       Using local mapper
<2cd1900>       Locals starting at 0x00000000041C7378 for 0x0000000000000002 slots
<2cd1900>               I-Slot: a0[0x00000000041C7378] = 0x00000007FAC238A0
<2cd1900>               I-Slot: a1[0x00000000041C7370] = 0x00000007F541D628 <----------

> j9object 0x00000007F541D628
J9VMJavaLangString at 0x00000007F541D628 {

struct J9Class* clazz = !j9class 0x2842B00   // java/lang/String
Object flags = 0x00000000;
[C value = !fj9object 0xea79e6d3 (offset=0) (java/lang/String)
I count = 0x0000002C (offset=4) (java/lang/String)
I hashCode = 0xAFBB2FA7 (offset=8) (java/lang/String)
"org.codehaus.plexus.archiver.zip.ZipArchiver"
...
<2cd1900> Bytecode frame: bp = 0x00000000041C7738, sp = 0x00000000041C7728, pc = 0x00000000156D83C3, cp = 0x0000000003AA90C0, arg0EA = 0x00000000041C7748, flags = 0x0000000000000000
<2cd1900>       Method: org/codehaus/plexus/classworlds/realm/ClassRealm.loadClass(Ljava/lang/String;)Ljava/lang/Class; !j9method 0x0000000003AA9B88
<2cd1900>       Bytecode index = 3
<2cd1900>       Using local mapper
<2cd1900>       Locals starting at 0x00000000041C7748 for 0x0000000000000002 slots
<2cd1900>               I-Slot: a0[0x00000000041C7748] = 0x00000007FAC238A0 <---- ----st-- Loader org/codehaus/plexus/classworlds/realm/ClassRealm(0x00000007FAC238A0), Parent *none*(0x0000000000000000)
<2cd1900>               I-Slot: a1[0x00000000041C7740] = 0x00000007F53FA858

> j9object 0x00000007F53FA858
J9VMJavaLangString at 0x00000007F53FA858 {

struct J9Class* clazz = !j9class 0x2842B00   // java/lang/String
Object flags = 0x00000000;
[C value = !fj9object 0xea79e6a5 (offset=0) (java/lang/String)
I count = 0x0000002C (offset=4) (java/lang/String)
I hashCode = 0x180E749B (offset=8) (java/lang/String)
"org.codehaus.plexus.archiver.jar.JarArchiver"

Against the relationships of the requested classes:
JarArchiver--> ZipArchiver --> AbstractZipArchiver --> AbstractArchiver ---> AbstractLogEnabled

> dumpromclass  0x000000001C097450
ROM Size: 0x2960 (10592)
Class Name: org/codehaus/plexus/archiver/jar/JarArchiver
Superclass Name: org/codehaus/plexus/archiver/zip/ZipArchiver

> dumpromclass 0x000000001C02D9F8
ROM Size: 0x140 (320)
Class Name: org/codehaus/plexus/archiver/zip/ZipArchiver
Superclass Name: org/codehaus/plexus/archiver/zip/AbstractZipArchiver

> dumpromclass 0x000000001C02DB38
ROM Size: 0x2d48 (11592)
Class Name: org/codehaus/plexus/archiver/zip/AbstractZipArchiver
Superclass Name: org/codehaus/plexus/archiver/AbstractArchiver

> dumpromclass 0x000000001C030880
ROM Size: 0x3910 (14608)
Class Name: org/codehaus/plexus/archiver/AbstractArchiver
Superclass Name: org/codehaus/plexus/logging/AbstractLogEnabled
Interfaces (4):
  org/codehaus/plexus/archiver/Archiver
  org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable
  org/codehaus/plexus/archiver/FilterEnabled
  org/codehaus/plexus/archiver/FinalizerEnabled

It turns out it was the same classloader 0x00000007FAC238A0 that was loading all parent classes from JarArchiver, which seems logically correct for class loading.

If so, it looks weird that it crashed when loading AbstractArchiver() as there were a bunch of classloaders (org/codehaus/plexus/classworlds/realm/ClassRealm) successfully loaded AbstractArchiver according to the java core.
e.g.

2CLTEXTCLLOAD  		Loader org/codehaus/plexus/classworlds/realm/ClassRealm(0x0000000759BFF400)
...
3CLTEXTCLASS   			org/codehaus/plexus/archiver/jar/JarArchiver(0x00000000049D8F00)
3CLTEXTCLASS   			org/codehaus/plexus/archiver/zip/ZipArchiver(0x00000000049D7B00)
3CLTEXTCLASS   			org/codehaus/plexus/archiver/zip/AbstractZipArchiver(0x00000000049D7200)
3CLTEXTCLASS   			org/codehaus/plexus/archiver/AbstractArchiver(0x00000000049D5F00)
3CLTEXTCLASS   			org/codehaus/plexus/archiver/FinalizerEnabled(0x00000000049D4500)
3CLTEXTCLASS   			org/codehaus/plexus/archiver/FilterEnabled(0x00000000049D4300)

@ChengJin01
Copy link

ChengJin01 commented Mar 11, 2019

Considering the mess in the native stack as follows:

3XMTHREADINFO3           Native callstack:
4XENATIVESTACK       -----> memcmp+0x10 (0x000000006A91BDC0 [MSVCR100+0x3bdc0])
4XENATIVESTACK               J9_CreateJavaVM+0x4d1b3 (0x000007FEE92C4823 [j9vm29+0xd4823])
4XENATIVESTACK               J9_CreateJavaVM+0x8e60d (0x000007FEE9305C7D [j9vm29+0x115c7d])
4XENATIVESTACK               J9_CreateJavaVM+0x8ed45 (0x000007FEE93063B5 [j9vm29+0x1163b5])
4XENATIVESTACK               J9_CreateJavaVM+0x4d391 (0x000007FEE92C4A01 [j9vm29+0xd4a01])
4XENATIVESTACK               J9_CreateJavaVM+0x4d77b (0x000007FEE92C4DEB [j9vm29+0xd4deb])
4XENATIVESTACK               J9_CreateJavaVM+0x4daf9 (0x000007FEE92C5169 [j9vm29+0xd5169])
4XENATIVESTACK               (0x000007FEE926454A [j9vm29+0x7454a])
4XENATIVESTACK               (0x000007FEE9264878 [j9vm29+0x74878])
4XENATIVESTACK               (0x000007FEE926502D [j9vm29+0x7502d])
4XENATIVESTACK               (0x000007FEE9266916 [j9vm29+0x76916])
4XENATIVESTACK               J9_CreateJavaVM+0x59a57 (0x000007FEE92D10C7 [j9vm29+0xe10c7])
4XENATIVESTACK               Java_java_lang_ref_Reference_waitForReferenceProcessingImpl+0x1998 (0x000007FEEBCBE428 [jclse7b_29+0xe428])
4XENATIVESTACK   ------>  Java_java_lang_ClassLoader_defineClassImpl+0xab (0x000007FEEBCB2A6B [jclse7b_29+0x2a6b])
4XENATIVESTACK               J9_CreateJavaVM+0x8b973 (0x000007FEE9302FE3 [j9vm29+0x112fe3])
4XENATIVESTACK               J9_CreateJavaVM+0x8b54c (0x000007FEE9302BBC [j9vm29+0x112bbc])
4XENATIVESTACK               (0x000007FEE9205970 [j9vm29+0x15970])

the only calling path that might correlate Java_java_lang_ClassLoader_defineClassImpl to memcmp is:
defineClassImpl --> defineClassCommon ---> romClassLoadFromCookie --> memcmp

/runtime/jcl/common/clsldr.cpp
jclass JNICALL  Java_java_lang_ClassLoader_defineClassImpl(JNIEnv *env, ...)
{
...
	return defineClassCommon(env, receiver, className, classRep, offset, length, protectionDomain, 0, NULL);
}
/runtime/jcl/common/jcldefine.c
jclass  defineClassCommon(JNIEnv *env, jobject classLoaderObject,...)
{
	if (isContiguousClassBytes) {
		/* Always re-load the classBytes pointer, as GC required in OutOfMemory case may have moved things */
		/* TMP_J9JAVACONTIGUOUSARRAYOFBYTE_EA returns I_8 * (since Java bytes are I_8) so this cast will silence the warning */
--->    classBytes = (U_8 *) TMP_J9JAVACONTIGUOUSARRAYOFBYTE_EA(currentThread, *(J9IndexableObject **)classRep, offset);
	}

	/* skip if we are anonClass */
	if (J9_ARE_NO_BITS_SET(options, J9_FINDCLASS_FLAG_ANON)) {
		/* Check for romClass cookie, it indicates that we are  defining a class out of a JXE not from class bytes */

-----> loadedClass = vmFuncs->romClassLoadFromCookie(currentThread, utf8Name, utf8Length, classBytes, (UDATA) length);
...

/runtime/vm/romutil.c
J9ROMClass *
romClassLoadFromCookie (J9VMThread *vmStruct, U_8 *clsName, UDATA clsNameLength, U_8 *romClassBytes, UDATA romClassLength)
{
	J9ROMClass *loadedClass = NULL;
	J9ROMClassCookie *cookie;

	/* check for Cookie in the romClassBytes */
	if ( romClassLength >= sizeof(J9ROMClassCookie) ) {
		U_8 romClassCookieSig[] = J9_ROM_CLASS_COOKIE_SIG;
		cookie = (J9ROMClassCookie *)romClassBytes; <----- might be an invalid address
-------> if (memcmp(cookie->signature, romClassCookieSig, J9_ROM_CLASS_COOKIE_SIG_LENGTH) != 0) {   ...

If so, then the problem should be related to the bogus cookie (which was re-allocated by GC in defineClassCommon()), which might need the GC team to get involved in the investigation.
FYI: @dmitripivkine

@dcendents, does the crash (with -Xint specified) occur every time or just intermittently?

@dcendents
Copy link
Author

Every time. I have a lot of projects in eclipse, I normally would only open the projects I work on, but when I switched to OpenJ9 I thought i'd stress it a bit to see how it performed and opened all the projects and rebuilt them all.

Every single time it crashed before completing the workspace build.

I only tried once with -Xint though. If I recall correctly it took longer before it crashed, but I'm not sure it actually built more of the projects (Just took longer to get there).

@ChengJin01
Copy link

ChengJin01 commented Mar 12, 2019

It looks like a bug out in our code. but first of all is to figure out where memcmp() in the crash came from as the dump was inaccurate for us to diagnose. I will compile a build (Java8 on Windows) with an assertion on the first argument (might be an invalid pointer or NULL) before all memcmps (without JIT) to determine the location of memcmp before it crashes.

@dcendents , is that possible to share your project plus the whole eclipse workspace with us? so we can reproduce the problem locally with a compiled build (this might involve your private data which need to be shared privately e.g via Google Drive instead of in the open).

@dcendents
Copy link
Author

@ChengJin01 no sorry this won't be possible. This is our customer's property and we signed an NDA.

If it can help I don't mind testing your build and sharing the dump files with you, but this is as far as I can go to help you guys figure out what the problem is. Sorry I can't do more.

@ChengJin01
Copy link

@dcendents, I already sent to you a link (via Google Drive) of another compiled build with a piece of code to check whether the value of a suspicious pointer is valid or not before calling memcmp() in a function, which helps to confirm the location of crash.

The build should crash on the added code rather than in memcmp(); otherwise, there might be other possibilities to trigger the crash.

@dcendents
Copy link
Author

@ChengJin01 the files are on my google drive

@ChengJin01
Copy link

ChengJin01 commented Mar 20, 2019

@dcendents , It seems there is nothing different in the dump files. So I compiled another build (already sent to you via Google Drive) by replacing the memcmp() (already commented out) with a FOR loop statement to check the whole array in that suspicious romClassLoadFromCookie().

If it still crashes in memcmp() on this build, it means the memcmp() comes from some where rather than romClassLoadFromCookie().

Another thing I want to confirm is, is that possible to increase the value of -Xmx in the eclipse.ini (e.g. over 6000m) to see what happens to the build if still crashes ? because we did notice in the verbose log that the memory was quite limited in the failing thread which triggered GC.

@dcendents
Copy link
Author

I did use the new build and increased the memory to 6GB. It still crashed, the files are on my google drive (eclipse-20190320-2.7z)

Also bear in mind that the previous setting I had (-Xmx3072m) does not crash without the -XVerify:none flag, so I would be inclined to think the culprit is not a lack of memory.

@ChengJin01
Copy link

ChengJin01 commented Mar 20, 2019

We already decoded the real native stack via Windbg as follows:

11 ntdll!KiUserExceptionDispatch+0x2e
12 msvcr100!memcmp+0x10
13 j9vm29!constraintHashEqualFn+0x23 [...\vm\bcverify\clconstraints.c @ 403] 
14 j9vm29!hashTableAddNodeInList+0x3d [...\vm\omr\util\hashtable\hashtable.c @ 575] 
15 j9vm29!hashTableAdd+0xd5 [...\vm\omr\util\hashtable\hashtable.c @ 554] 
16 j9vm29!registerClassLoadingConstraint+0x1b1 [...\vm\bcverify\clconstraints.c @ 235] 
17 j9vm29!j9bcv_checkClassLoadingConstraintForName+0x1bb [...\vm\bcverify\clconstraints.c @ 145] 
18 j9vm29!j9bcv_checkClassLoadingConstraintsForSignature+0x209 [...\vm\bcverify\clconstraints.c @ 107] 
19 j9vm29!processVTableMethod+0x1ca [...\vm\vm\createramclass.cpp @ 1253] 
1a j9vm29!computeVTable+0x218 [...\vm\vm\createramclass.cpp @ 845] 
1b j9vm29!internalCreateRAMClassFromROMClassImpl+0x518 [...\vm\vm\createramclass.cpp @ 2156] 
1c j9vm29!internalCreateRAMClassFromROMClass+0x696 [...\vm\vm\createramclass.cpp @ 3008] 
1d j9vm29!internalDefineClass+0x607 [...\vm\bcutil\defineclass.c @ 167] 
1e jclse29!defineClassCommon+0x51e [...\vm\jcl\common\jcldefine.c @ 203] 
1f jclse29!Java_java_lang_ClassLoader_defineClassImpl+0xa4 [...\vm\jcl\common\clsldr.cpp @ 64] 
20 0x4c40cb8c

Will check what happened to the corresponding code in there.

@ChengJin01
Copy link

ChengJin01 commented Mar 21, 2019

The core dump shows the crash occurred when the signature of method was NULL due to a non-NULL romMethod in which there is no value in there:

0:065> .frame 19
19 00000000`1ee2cd60 000007fe`e90e42d8 j9vm29!processVTableMethod+0x1ca [...\vm\createramclass.cpp @ 1253] 

0:065> dv  /i /t /V
prv param  00000000`1ee2cdf0 @rsp+0x0090       struct J9VMThread * vmThread = 0x00000000`046e6000
prv param  00000000`1ee2cdf8 @rsp+0x0098       struct J9ClassLoader * classLoader = 0x00000000`1d4ed920
prv param  00000000`1ee2ce00 @rsp+0x00a0       unsigned int64 * vTableAddress = 0x00000000`24548dc8
prv param  00000000`1ee2ce08 @rsp+0x00a8       struct J9Class * superclass = 0x00000000`03e99300
prv param  00000000`1ee2ce10 @rsp+0x00b0       struct J9ROMClass * romClass = 0x00000000`24547310
prv param  00000000`1ee2ce18 @rsp+0x00b8       struct J9ROMMethod * romMethod = 0x00000000`00000000 <-----
                                                       <---- there is no value in this romMethod
prv param  00000000`1ee2ce20 @rsp+0x00c0       unsigned int64 localPackageID = 0x29937531
prv param  00000000`1ee2ce28 @rsp+0x00c8       unsigned int64 vTableMethodCount = 0x28
prv param  00000000`1ee2ce30 @rsp+0x00d0       void * storeValue = 0x00000000`24548dc9
prv param  00000000`1ee2ce38 @rsp+0x00d8       struct J9OverrideErrorData * errorData = 0x00000000`1ee2d028

To figure out what happened to this romMethod, I need to compile another build with new tracepoints to double-check the corresponding romClass and the location of the failing romMethod in the romClass.

@ChengJin01
Copy link

@dcendents , I already sent to you the link of the compiled build (via Google Drive) with new tracepoints to keep track of the rom classes. Hopefully it should show us something related to the failing method in this rom class.

The option in Eclipse.ini remains the same as before to trigger the crash.

@dcendents
Copy link
Author

@ChengJin01 the dump files are on my drive (eclipse-20190322.7z)

@ChengJin01
Copy link

The snap trace indicates the crash occurred when handling the method getLogger()Lorg/codehaus/plexus/logging/Logger;

processVTableMethod: romClass at 0x24c14140 is org/codehaus/plexus/archiver/AbstractArchiver, 
preRomMethod at 0x24c15bb4 is setDestFile, sig: (Ljava/io/File;)V, 
romMethod at 0x24c15bf8 is getLogger, sig: ()Lorg/codehaus/plexus/logging/Logger;, <---------
Index = 38, methodRemapArrayIndex = 0, methodRemapArray = 0x0

but the trace is still incomplete as compared to the results with windbg. I need to add more tracepoints to a couple of functions around the crash.

@ChengJin01
Copy link

@dcendents, I just sent to you another compiled build with all tracepoints added. Theoretically it will show us what happened to those values before crash in memcmp.

@dcendents
Copy link
Author

@ChengJin01 eclipse will not start with that build

I've uploaded the dump files if that can be helpful (eclipse-20190325.7z).
Java seems to work OK though:

java.exe -version
openjdk version "1.8.0_202-internal"
OpenJDK Runtime Environment (build 1.8.0_202-internal-administrator_2019_03_24_08_37-b00)
Eclipse OpenJ9 VM (build master-200adb5da, JRE 1.8.0 Windows 7 amd64-64-Bit Compressed References 20190324_000000 (JIT enabled, AOT enabled)
OpenJ9   - 200adb5da
OMR      - da32e2b9
JCL      - 9dc1c4d81c based on jdk8u202-b08)

@ChengJin01
Copy link

@dcendents , the problem was caused by one of the new tracepoints which was incorrect in format (because we can't verify all of them locally). I will double-check and compile another one for you.

@ChengJin01
Copy link

ChengJin01 commented Mar 25, 2019

@dcendents , I already fixed the problem with tracepoint and compiled another build (jdk8_openj9_build_v5.zip shared via Google Drive) for you to check.

@dcendents
Copy link
Author

@ChengJin01 the dump files are on my drive (eclipse-2019-03-25-2.7z)

@ChengJin01
Copy link

According to the snaptrace generated from eclipse-2019-03-25-2.7z:

j9bcverify(j9vm).125 Event       registerClassLoadingConstraint: call hashTableAdd: exemplar = 0x1c1cc600, loader = 0x1c887d50, name =org/codehaus/plexus/logging/Logger, length = 34

it means the right_key (passed via exemplar ) was fine against the code below:

static UDATA  
constraintHashEqualFn(void *leftKey, void *rightKey, void *userData)
{
	J9ClassLoadingConstraint *left_k = leftKey;   <--------- need to check in the hashtable
	J9ClassLoadingConstraint *right_k = rightKey; <----- exemplar  = org/codehaus/plexus/logging/Logger
	J9JavaVM *vm = userData;

	return 
		(left_k->classLoader == right_k->classLoader) 
		&& (J9UTF8_DATA_EQUALS(left_k->name, left_k->nameLength, right_k->name, right_k->nameLength));
}

I need to split the tracepoint in constraintHashEqualFn() to check whether leftKey is a bogus pointer or not. If yes, the hashtable there might be messed up somehow.

@DanHeidinga
Copy link
Member

I'm actually surprised that we're registering classloading constraints if -Xverify:none is set. Most (?) uses of the constraint checking functions are guarded to not run if the verifier isn't enabled.

The hashtable could be messed up if class unloading occurred as the cleanup code only runs with the verifier enabled:
https://github.com/eclipse/openj9/blob/0096ddb073d0b8c4c488d1988e56aa1ba6e8a313/runtime/bcverify/bcverify.c#L2812-L2814

We may be missing some checks to only add constraints if the verifier is enabled,

@ChengJin01
Copy link

ChengJin01 commented Mar 26, 2019

I double-checked our code as to the check of classloading constraints (only via j9bcv_checkClassLoadingConstraintsForSignature) only when (vm->runtimeFlags & J9_RUNTIME_VERIFY) != 0 (the verifier library won't loaded with -Xverify:none specified) .

It seems such checks were already added except two places as follows (including the crash in this issue):
1)

addInterfaceMethods(..., J9OverrideErrorData *errorData)
{
...
if (interfaceLoader != vTableMethodLoader) { <---- check is missing
 if (0 != j9bcv_checkClassLoadingConstraintsForSignature(vmStruct, vTableMethodLoader, interfaceLoader, vTableMethodSigUTF, interfaceMethodSigUTF)) {

processVTableMethod(..., J9OverrideErrorData *errorData)
{
...
if (superclassVTableMethodLoader != classLoader) { <---- check is missing
J9UTF8 *superclassVTableMethodSigUTF = J9ROMMETHOD_SIGNATURE(superclassVTableROMMethod);
if (0 != j9bcv_checkClassLoadingConstraintsForSignature(vmThread, classLoader, superclassVTableMethodLoader, sigUTF, superclassVTableMethodSigUTF)) {

So the fix should be:
1)

addInterfaceMethods(..., J9OverrideErrorData *errorData)
{
...
if ((interfaceLoader != vTableMethodLoader)
&& J9_ARE_ANY_BITS_SET(vm->runtimeFlags, J9_RUNTIME_VERIFY) <-------- add check
) {
if (0 != j9bcv_checkClassLoadingConstraintsForSignature(vmStruct, vTableMethodLoader, interfaceLoader, vTableMethodSigUTF, interfaceMethodSigUTF)) {


processVTableMethod(..., J9OverrideErrorData *errorData)
{
...
if ((superclassVTableMethodLoader != classLoader)
&& J9_ARE_ANY_BITS_SET(vm->runtimeFlags, J9_RUNTIME_VERIFY) <---- add check
) {
J9UTF8 *superclassVTableMethodSigUTF = J9ROMMETHOD_SIGNATURE(superclassVTableROMMethod);

I will compile a build with the fix above to see whether it works to avoid the crash as expected.

@ChengJin01
Copy link

@dcendents , just sent to you the link of two builds (via Google Drive):
jdk8_openj9_build_v6 is used to confirm the corrupt hash table for class loading constraints.
jdk8_openj9_build_fix_v1 with the fix above is to avoid the crash when the verifier is disabled with -Xverify:none

@dcendents
Copy link
Author

@ChengJin01 I tested with both builds.

It did crash with v6 (although it seemed to build for much longer than usual before it crashed). The dump files are on my drive (eclipse-20190326.7z)

As expected the fix_v1 worked, the build completed successfully. 😄

@ChengJin01
Copy link

ChengJin01 commented Mar 26, 2019

@dcendents, many thanks for your confirmation with the expected results.

I already checked the dump files and they indicates the crash occurred when printing the class name on the left_key (from the hash table) in the added tracepoint (it was added to trigger the crash on the left_key if it was messed up), which means the hash table was corrupt at that time.

As mentioned above, the hash table for class loading constraints should never be used with -Xverify:none specified. I will create a PR for the fix soon as it resolved the problem.

ChengJin01 pushed a commit to ChengJin01/openj9 that referenced this issue Mar 27, 2019
The change is to avoid checking the class loading contraints
when the verifier is disabled by -Xverify:none.

Close: eclipse-openj9#4904

Signed-off-by: Cheng Jin <jincheng@ca.ibm.com>
ChengJin01 pushed a commit to ChengJin01/openj9 that referenced this issue Mar 27, 2019
The change is to avoid checking the class loading constraints
when the verifier is disabled by -Xverify:none.

Fix: eclipse-openj9#4904

Signed-off-by: Cheng Jin <jincheng@ca.ibm.com>
@dcendents
Copy link
Author

Hi,

I just want to confirm I tested again using the official 0.14.0 build (OpenJDK8U-jdk_x64_windows_openj9_8u212b03_openj9-0.14.0) and as expected I did not have any problem.

Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants