Java 7 GA was released today, but as noted by Uwe Schindler, there are some very frightening bugs in HotSpot Loop optimizations that are enabled by default. In the best case scenario, these bugs cause the JVM to crash. In the worst case scenario, they cause incorrect execution of loops.
Bottom Line: Don’t use Java 7 for anything (unless maybe you know you don’t have any loops in your java code)
UPDATE OCTOBER 28, 2011: As noted on Uwe’s blog, Java 7u1 is documented to include the patches to address these issues.
From: Uwe Schindler
Date: Thu, 28 Jul 2011 23:13:36 +0200
Subject: [WARNING] Index corruption and crashes in Apache Lucene Core / Apache Solr with Java 7
Hello Apache Lucene & Apache Solr users,
Hello users of other Java-based Apache projects,
Oracle released Java 7 today. Unfortunately it contains hotspot compiler
optimizations, which miscompile some loops. This can affect code of several
Apache projects. Sometimes JVMs only crash, but in several cases, results
calculated can be incorrect, leading to bugs in applications (see Hotspot
bugs 7070134 [1], 7044738 [2], 7068051 [3]).
Apache Lucene Core and Apache Solr are two Apache projects, which are
affected by these bugs, namely all versions released until today. Solr users
with the default configuration will have Java crashing with SIGSEGV as soon
as they start to index documents, as one affected part is the well-known
Porter stemmer (see LUCENE-3335 [4]). Other loops in Lucene may be
miscompiled, too, leading to index corruption (especially on Lucene trunk
with pulsing codec; other loops may be affected, too – LUCENE-3346 [5]).
These problems were detected only 5 days before the official Java 7 release,
so Oracle had no time to fix those bugs, affecting also many more
applications. In response to our questions, they proposed to include the
fixes into service release u2 (eventually into service release u1, see [6]).
This means you cannot use Apache Lucene/Solr with Java 7 releases before
Update 2! If you do, please don’t open bug reports, it is not the
committers’ fault! At least disable loop optimizations using the
-XX:-UseLoopPredicate JVM option to not risk index corruptions.
Please note: Also Java 6 users are affected, if they use one of those JVM
options, which are not enabled by default: -XX:+OptimizeStringConcat or
-XX:+AggressiveOpts
It is strongly recommended not to use any hotspot optimization switches in
any Java version without extensive testing!
In case you upgrade to Java 7, remember that you may have to reindex, as the
unicode version shipped with Java 7 changed and tokenization behaves
differently (e.g. lowercasing). For more information, read
JRE_VERSION_MIGRATION.txt in your distribution package!
On behalf of the Lucene project,
Uwe
[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7070134
[2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7044738
[3] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7068051
[4] https://issues.apache.org/jira/browse/LUCENE-3335
[5] https://issues.apache.org/jira/browse/LUCENE-3346
[6] http://s.apache.org/StQ
[...] Don’t use Java 7 for anything http://www.lucidimagination.com/blog/2011/07/28/dont-use-java-7-for-anything/ [...]
July 29, 2011 00:07 — pandroid » #10 NFC und Ben und BLA
I use Java 7 extensively, I would love to see sample codes that cause this bug, I have not been able to replicate it.
Thanks
July 29, 2011 01:32 — Akintayo Olusegun
Meta-Comment: Horizontal scrollbars suck (especially when there’s also a vertical scrollbar). An F for usability.
July 29, 2011 01:59 — Norman N.
Your text box sucks ass.
July 29, 2011 02:33 — Greg
[...] [...]
July 29, 2011 02:37 — Oracle Java SE Runtime Environment 7
[...] As ever, upgrade critical machines with caution. In particular, Apache Lucene and Apache Solr do not work on Java 7 because of HotSpot optimization bugs. window.fbAsyncInit = function() { FB.init({appId: [...]
July 29, 2011 02:42 — Java Standard Edition 7 is done, but feels like an interim release « Tim Anderson’s ITWriting
Putting a fixed-width, fixed-font quotation in a fixed-width column stylesheet does nothing for the readability.
July 29, 2011 04:03 — Andrew Gallagher
Java 7 != HotSpot
July 29, 2011 04:24 — Anon
Finding this one a little hard to believe. Sorry, but anyone familiar with a release process would be suspicious of an announcement like this coming so soon after the release
July 29, 2011 04:33 — CptBongue
That’s unbelievable. Well, .NET, Ruby, PHP and Python are always options to use just to name a few. They don’t have critical bugs in their stable versions and you needn’t worry about their licensing either.
Seems to me Java is just going downhill since Oracle took over and I can’t see where it will stop.
July 29, 2011 04:59 — John C
[...] [...]
July 29, 2011 05:13 — Anonymous
really depends on what oracle does. a) they could be poisoning the well; and b) they could just be really bad for java business.
In internet speed/time, java has lived long enough to go to the place where COBOL lives.
July 29, 2011 05:44 — richard
Correction: Don’t Use Java For Anything. It is a big bloated piece of garbage that needs to be abandoned.
July 29, 2011 05:53 — Enzo
Sun’s shenanigans with Google over their use of Java is a good indicator of just how secure you are when you build your house on Java’s foundation…
July 29, 2011 06:18 — Benjamin Smith
[...] with Java, but alas we are in C# land. Apparently the initial release contains bugs that can “cause incorrect execution of loops“. Yick. I’m sure they will get that all sorted out. I guess all I have to worry about [...]
July 29, 2011 06:42 — Java 7 is out and about | BoxThoughts
To all the folks who commented on the use of horizontal scrollbars on the “pre” tag: I agree with you completely, and appreciate your feedback. I have forwarded your comments to the people who control the look/feel of this site.
I thought it was clear, but the “Don’t use Java 7″ link will take you to a copy of the original email in our archive.
July 29, 2011 08:28 — hossman
Horizontal scrolling textboxes make baby jesus cry.
July 29, 2011 09:30 — Jack Tors
Akintayo: The simplest example (I know of) of the sigsev problem can be found by trying to run the Porter Stemmer code (used in Solr, Eclipse, etc…) as mentioned in java bug#7070134
–CUT–
curl http://tartarus.org/~martin/PorterStemmer/java.txt > Stemmer.java
javac Stemmer.java
java Stemmer /usr/share/dict/words
–CUT–
The “wrong loops” problem is definitely tricker to isolate, but if you look at the mentioned Lucene issues, there are steps to reproduce the problem in Lucene JUnit tests
July 29, 2011 09:34 — hossman
Anon: While it’s true that “Java7 != HotSpot”, the real issue here is that the optimizations that have these bugs are enabled by default in the Java 7 releases.
July 29, 2011 09:38 — hossman
So, if the bug is present in JSE6 as well (even if the optimizations are actually disabled by default), why is this being blamed on Oracle?
July 29, 2011 09:38 — Bryant
Bryant: Because they enabled those optimizations by default without community testing. Stupid demonstration apps that only execute loops 5 times are no real testing.
In fact the problems in Java 6 only exist since the time when Oracle aquired Sun (approx 1.6.0_20).
July 29, 2011 09:47 — Uwe
“why is this being blamed on Oracle?”
Because they FAILED to use adequate QA procedures.
July 29, 2011 09:49 — F
Bryant: I don’t think you’ll see anything in this post (or in Uwe’s email) that “blames” Oracle for anything.
In general I think the main concern is that the release would go forward with these buggy optimizations in HotSpot enabled by default — particularly if you look at the dates some of these bugs were posted @ bugs.sun.com.
July 29, 2011 09:50 — hossman
Java 7 also breaks the USPTO’s e-filing system (Entrust)–with a delicious sort of irony–no patent attorneys can log into file patents if they upgrade to JRE 7.
July 29, 2011 10:01 — Indy
“These problems were detected only 5 days before the official Java 7 release, so Oracle had no time to fix those bugs”
This official statement from Oracle speaks volumes about how their schedule is more important than product quality.
Responsible companies reschedule releases when major bugs arise, no matter the schedule impact. People can keep using the beta build until the bugs are fixed correctly.
July 29, 2011 10:03 — F
“pre” tag and wordpress don’t get along. Apologies all of you who got to ‘enjoy’ scrolling. It’s fixed now.
July 29, 2011 10:19 — David M. Fishman
A reasonable person NEVER upgrades to the latest version ASAP …they wait for the fallout before making upgrade decisions.
July 29, 2011 11:00 — flunkie
amen to that…
July 29, 2011 11:48 — PM
amen to that @flunkie
July 29, 2011 11:49 — PM
workaround is to run with -XX:-UseLoopPredicate
July 29, 2011 11:59 — diego
[...] Don’t Use Java 7, For Anything (tags: java oracle lucene java7 bugs) [...]
July 29, 2011 12:12 — links for 2011-07-29 « that dismal science
If you don’t blame Oracle, who do you blame? There is no Sun any more. This might still have happened if Sun were running the show, but as there is no longer any Sun, Oracle is the only place to lay blame.
July 29, 2011 12:18 — JohnS
Come on you negative pos people here. Some people complain about Java. Why are you even here commenting? I’m so sick of negative comments. Java is great and enables cross platform programs and also Android. It’s simple, clear, has threads, high performance and the most pleasant programming language in my opinion.
July 29, 2011 12:19 — Come on
Stop spreading FUD lamers. Check the oracle bug database, this has been fixed in 1.6 since u25.
Give what version its broken in and if fixed then tell us what version it’s been fixed in.
http://download.java.net/jdk6/6u25/promoted/b01/changes/JDK6u25.b01.list.html
July 29, 2011 12:25 — chimera8
[...] from Apache have suggested that the bug may have been present in Java 6 (but has apparently been fixed in the Java 6 u25 service release), but with the optimization flags enabled by default in Java 7, the issue becomes more [...]
July 29, 2011 13:05 — Java 7 Bug Discovered | Nitin's Blog
If you disable loop optimizations, you can still use Java 7 for developing applications if performance is not critical.
July 29, 2011 13:06 — Nitin Reddy Katkam
[...] Don’t Use Java 7, For Anything [...]
July 29, 2011 13:10 — Java7 ships with critical bug « Hornet Dear Bernard
chimera8: Try JDK 1.6.0_26 with -XX:+AggresiveOpts and run the Porter example application from the bug report. What happens? Yes it crashes you JVM, so which bug is fixed in u25?
July 29, 2011 13:18 — Uwe
[...] out, and the official version was released earlier this week. Now that it's out, and apart from some serious bugs, what do you think about [...]
July 29, 2011 15:01 — Hacker Poll: What Do You Think of Java 7? at Ectimes
[...] and the official version was released earlier this week. Now that it’s out, and apart from some serious bugs, what do you think about [...]
July 29, 2011 15:01 — Hacker Poll: What Do You Think of Java 7? | TechDiem.com
[...] out, and the official version was released earlier this week. Now that it's out, and apart from some serious bugs, what do you think about [...]
July 29, 2011 15:02 — Hacker Poll: What Do You Think of Java 7?
-XX:-UseLoopPredicate
July 29, 2011 15:09 — Robert
[...] and the official version was released earlier this week. Now that it’s out, and apart from some serious bugs, what do you think about [...]
July 29, 2011 16:01 — Hacker Poll: What Do You Think of Java 7? | Techlies - News for the Herd - Headlines that Shatter
[...] Lucid Imagination » Don’t Use Java 7, For Anything RT @_navin: WTF?! "Don't use Java 7 for anything, unless you have no loops in your program" http://j.mp/rcd56X (tags: via:packrati.us) This entry was posted on Saturday, July 30th, 2011 at 7:31 am and is filed under Bookmarks. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site. [...]
July 29, 2011 18:01 — » links for 2011-07-29 (Dhananjay Nene)
[...] lucidimagination.com ha appena pubblicato un annuncio su un bug grave nella recente pubblicazione della versione Java 7. Pare che alcuni cicli non compilati bene siano [...]
July 29, 2011 22:45 — Java 7 viene fornito con grave bug
Bottom line: Java 7 must be so good that the FUD campaign has already started.
Too bad everyone else disagrees with LUCID´s doom and gloom post.Including RedHat…
Java Resurgence
http://www.ctoedge.com/content/java-resurgence
I have ran several Java apps and haven´t found this optimization bug. In fact, I had no crashes at all. Maybe all the apps I´ve tested contain no loops at all? I find that hard to believe.
Seems like a FUD campaign to try to rain on Oracle´s Java 7 launch parade, if you ask me.
Didn´t Lucid take part in the Java7 beta testing process?
Are your concerns present in verifiable OpenJDK7 bug reports?
FC
July 30, 2011 03:45 — Fernando Cassia
[...] 在「Don’t Use Java 7, For Anything」這篇就更直接了,直接說 Java 7 目前是個不能用的 GA Product: Don’t use Java 7 for anything (unless maybe you know you don’t have any loops in your java code) [...]
July 30, 2011 03:49 — 最近出新版的 Java 7 的 bug… | Gea-Suan Lin's BLOG
“t: Because they enabled those optimizations by default without community testing”: Lucene devs did not test their app with the beta versions of Java 7, or (even with the optimization features in java 6 enabled) before. They had maybe one year to test and they did not). Beta versions of Java 7 are available for years, and discussion on these bugs is free on OpenJDK mailings lists, apart from the by database.
July 30, 2011 04:59 — Hervé
[...] the first exception to this rule. It hadn’t even been a day after Java 7′s release when bugs surfaced. Internal testing can never compete with the testing that takes place through mass adoption. Oracle [...]
July 30, 2011 05:05 — Java 7 bugs surface and workaround known - Dhruba Bandopadhyay
[...] the first exception to this rule. It hadn’t even been a day after Java 7′s release when bugs surfaced. Internal testing can never compete with the testing that takes place through mass adoption. Oracle [...]
July 30, 2011 05:06 — Java 7 loop predication bugs surface and workaround known - Dhruba Bandopadhyay
Ok, after lots of reading through sky-is-falling posts, I finally gathered:
1. that Oracle learned about it 5 days before GA release, and promised a fix for the first JDK7 security update
2. that Java 6 users are also affected, if they enable
http://pages.citebite.com/d9y2u1i5bnjm
3. That this doom and gloom bug (according to tweets) actually affects very specific conditions, and there is a work-around.
—–
> This means you cannot use Lucene/Solr with Java 7 releases before Update 2! If you do, please don’t open bug reports, it is not the committers’ fault! At least disable loop optimizations using the -XX:-UseLoopPredicate JVM options
—–
4. As usual h-online has some of the best, in-depth reporting when it comes to Java, without apocalypse headlines
Java 7 paralyses Lucene and Solr
http://www.h-online.com/open/news/item/Java-7-paralyses-Lucene-and-Solr-1288210.html
5. “Don´t use Java 7, for *anything*” seems to me like an extreme headline given the availability of a work-around (point #3 above).
FC
July 30, 2011 05:45 — Fernando Cassia
[...] out, and the official version was released earlier this week. Now that it's out, and apart from some serious bugs, what do you think about [...]
July 30, 2011 12:25 — Hacker Poll: What Do You Think of Java 7? | Scripting4U Blog
[...] Detectados errores graves en Java 7 http://www.lucidimagination.com/blog/2011/07/28/dont-use-java-7-… por Ratchet hace 2 segundos [...]
July 31, 2011 06:32 — Detectados errores graves en Java 7
[...] [...]
July 31, 2011 09:44 — Java 7 features in scripts are not allowed
I posted the whole story about the Java 7 issue here: http://blog.thetaphi.de/2011/07/real-story-behind-java-7-ga-bugs.html
July 31, 2011 09:55 — Uwe
> These problems were detected only 5 days before the
> official Java 7 release, so Oracle had no time to fix
> those bugs,
Hogwash. They had five days to fix it. They could have postponed the release until a fix was available.
July 31, 2011 17:01 — ThomasW
Uwe: I tried it with 1.6.0_25. Ran it and it worked. No problems. Tried it about 10 times still works. Can’t seem to get the random factors to align on my box like you can to make it crash. Doesn’t seem reproducible in 1.6.0_25.
Maybe it’s just Java 7 and all the rest of us running apps on Java6 don’t have to freak out?
curl http://tartarus.org/~martin/PorterStemmer/java.txt > Stemmer.java
javac Stemmer.java
java -server -XX:+AggressiveOpts -cp . Stemmer american* british* canadian* english* variant*
> wc -l all_words
706308 total
August 1, 2011 04:25 — chimera8
Chimera8: Maybe it only crashes 64 bit JVMs with SIGSEGV on Java6?
I am in contact with the responsible Oracle developer and he confirms crashes:
“The code in memnode.cpp was there for long time (before 6u26). But before my changes it was guarded by OptimizeStringConcat flag. So if you use -XX:+OptimizeStringConcat or -XX:+AggressiveOpts flags you will hit the same problem (I reproduced it even with 1.6.0_23). The report you pointed misses the rest of hs_err file which should have used flags so it is unclear what flags they used. Vladimir”
August 1, 2011 05:44 — Uwe
[...] prompted a number of alarmist articles, such as “Don't use Java 7 for anything” which implied that all loops were problematic. In fact, although there is a valid bug (in which [...]
August 1, 2011 19:19 — Java7 Hotspot Loop Bug Details | BugBoard
[...] bug está relacionado con loops y desató noticias alarmistas en las que se decía que no es seguro usar Java 7 a menos que se garantice que el programa no [...]
August 2, 2011 21:33 — La salida de Java 7 acompañada de un bug
Oh come on “Don’t Use Java 7, For Anything” – the 3 bugs are reported for the server VM only.
You’re post is just a “I hate Java” post.
August 5, 2011 04:23 — come on
[...] and the official version was released earlier this week. Now that it’s out, and apart from some serious bugs, what do you think about [...]
August 5, 2011 11:57 — Hacker Poll: What Do You Think of Java 7? | بهترین ها|behtarinha|مطالب جالب|دانلود نرم افزار|دانلود بازی|اس ام اس|جک|خفن|فال|همه چیز
[...] 7 ships. Caveat – a very serious bug has already been [...]
August 6, 2011 10:12 — State of Technology #19 « Dr Data's Blog
[...] (cosa que descubrió una semana antes del release final de Java 7). Esto ha llevado a algunos a recomendar no usar Java 7 para nada (en producción), recomendación que probablemente en estos momentos sea un buen [...]
August 7, 2011 17:38 — Java 7 tiene un bug en el compilador Hotspot | MiguelMathus.com
[...] There’s long been and unwritten rule for Oracle Database users: “Never use R1 of the product, always wait for R2″.This was especially true with Database 10g. Now it seems this same issue has come to Java, with Java 7 being released with some glaring issues, Oracle early adopters known this path well. Its a pity, as before now, Java releases tended to be uptaken pretty quickly. Lucid Imagination » Don’t Use Java 7, For Anything [...]
August 8, 2011 01:20 — Oracle software standards come to Java | Ronan's Blog
[...] Use Java 7, For Anything [zz] 08.10.2011, 技术生活, by Jay, 被踩了 9 脚. From here. Shit happens, Oracle wanna risk the fame of [...]
August 10, 2011 00:09 — Don’t Use Java 7, For Anything [zz] | 拈花微笑
>> These problems were detected only 5 days before the
>> official Java 7 release, so Oracle had no time to fix
>> those bugs,
> Hogwash. They had five days to fix it. They could have
> postponed the release until a fix was available.
They could have also, at a bare minimum, have simply changed those buggy options not be on by default and proceeded with the release on time.
August 10, 2011 20:55 — Eric S
[...] envuelto en polémica puesto que, cinco días antes del lanzamiento, se descubrió un bug que afectaba a la correcta ejecución de bucles en la JVM HotSpot. Oracle decidió no posponer el lanzamiento oficial y sugirió, como solución temporal, la [...]
August 14, 2011 21:48 — Java7 | Bonillaware
I use Java 7… have got plenty of loops.. haven’t encountered any bugs yet.
August 15, 2011 08:22 — Jamis
[...] This post was Twitted by cabodj [...]
August 23, 2011 17:59 — Twitted by cabodj
It’s alarmist overreactions like this that cause soooooooo many problems on the internet, and in the development community. Please refrain from doing things like this in the future. I even suggest deleting this posting.
This bug only occurs under very specific and not too common circumstances. And you can easily be worked around (while waiting for the fix in Java 7 Update 1) via a compiler switch (-XX:-UseLoopPredicate). Readers might want to read http://www.infoq.com/news/2011/08/java7-hotspot for a rational discussion of this MINOR issue.
August 25, 2011 19:42 — Dilbert
So.. Is this bug fixed now? Could we get another blog post giving Java7 the “All Clear” at least with regards to known bugs?
September 12, 2011 12:38 — Fernando Padilla
FYI: Please note the update.
Last week, Java “7u1″ was released, and although the release notes didn’t mention the specific bugs in question, testing suggested that it seemed to resolve the known problems. After Uwe posted a blog on this, the Java 7u1 release notes were updated to reflect that the specific patches had been applied…
http://blog.thetaphi.de/2011/10/java-7-update-1-released-does-it-fix.html
(My apologies for not posting this update earlier, but I was on vacation last week)
October 28, 2011 10:12 — hossman
[...] Hi Dave,I think this error possibly related to HSQL or JAVA 7. Regarding to JAVA 7 please check whether you have the latest version as formerly it had some issues. Please check this post for details: http://www.lucidimagination.com/blog/2011/07/28/dont-use-java-7-for-anything/Regards,Vilmos [...]
November 4, 2011 14:35 — RE: Cannot add user to usergroup - Forums - Liferay.com
[...] took nearly 5 years after the release of Java 6 in December 2006, but still it shipped with bugs (example). But now after two updates (Update 1 in Oct 2011 and Update 2 in Dec 2011) you might seriously [...]
April 1, 2012 00:52 — Java 7: New Features | Manish Chhabra's Blog