Bug 94716 - FILEOPEN: LibO terminates when loading Oracle's Java JRE on OS X 10.10 and 10.11
Summary: FILEOPEN: LibO terminates when loading Oracle's Java JRE on OS X 10.10 and 10.11
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All macOS (All)
: medium major
Assignee: Andras Timar
URL: http://bugs.java.com/bugdatabase/view...
Whiteboard: target:5.1.0
Keywords:
: 95774 99841 101954 104765 (view as bug list)
Depends on:
Blocks: Java-Runtime-JRE
  Show dependency treegraph
 
Reported: 2015-10-03 00:24 UTC by Patrick (volunteer)
Modified: 2016-12-20 21:54 UTC (History)
12 users (show)

See Also:
Crash report or crash signature:


Attachments
Patch against Go-oo 3.1.1.1 code (12.19 KB, patch)
2015-10-03 00:24 UTC, Patrick (volunteer)
Details
Updated patch with unnecessary USE_JAVA macros removed (11.84 KB, patch)
2015-10-03 01:16 UTC, Patrick (volunteer)
Details
Patch to remove LibreOffice OS X code that conflicts with code changes in previous patch (704 bytes, patch)
2015-10-04 20:14 UTC, Patrick (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick (volunteer) 2015-10-03 00:24:52 UTC
Created attachment 119220 [details]
Patch against Go-oo 3.1.1.1 code

When LibreOffice on OS X 10.10 or 10.11 and LibreOffice loads Oracle's Java 1.8.x via JNI, the JVM terminates LibreOffice. This bug occurs only when only Oracle's JDK or JRE are installed and Apple's Java is *not* installed.

Attached is a patch for the jvmfwk module that shows how to fix this bug. Please note that this patch will likely not apply without error as the patch is a diff between our - Planamesa Inc.'s - NeoOffice code and Go-oo 3.1.1.1.

By posting the attached patch, Planamesa Inc. makes the contents of the patch available under the terms the MPL / LGPLv3+ per our license statement in the following link:

http://lists.freedesktop.org/archives/libreoffice/2015-October/070432.html
Comment 1 Patrick (volunteer) 2015-10-03 01:16:51 UTC
Created attachment 119221 [details]
Updated patch with unnecessary USE_JAVA macros removed

Simplify patch by removing the USE_JAVA macros as they are only used in NeoOffice builds.
Comment 2 Julien Nabet 2015-10-03 07:36:13 UTC
On which LO version are you?
Indeed Oracle 1.7.0 min version is present in master sources, see http://opengrok.libreoffice.org/xref/core/jvmfwk/distributions/OpenOfficeorg/javavendors_macosx.xml
Comment 3 tommy27 2015-10-03 09:26:37 UTC
@Planamesa
are you going to share other NeoOffice codefix to the LibO project?
this would be very appreciated
Comment 4 Michael Meeks 2015-10-03 12:13:45 UTC
Andras - any chance you can take a look at this one =) The patch is vs. 3.1.1 - so it will need forward porting, and (of course) some testing vs. master to see  we still have the same issue.

Thanks ! =)
Comment 5 Patrick (volunteer) 2015-10-03 15:28:49 UTC
There are some additional details about the patch:

1. This bug only occurs when you Apple's Java is *not* installed. Apparently, the Oracle JVM loads a library in Apple's JVM and, when Apple's Java is not installed, Apple's stub library invokes exit().

2. The patch will only allow Oracle's JDK, not their JRE to be used. Oracle's JRE will refuse to load via JNI but Oracle's JDK can be loaded via JNI by adding missing values to the JDK's [NSBundle dictionary] immediately before the first JNI call.
Comment 6 Andras Timar 2015-10-04 17:48:18 UTC
I confirm that when LibreOffice on OS X 10.10 loads Oracle's Java 1.8.x via JNI, and Apple's Java is *not* installed, then JVM terminates LibreOffice.

I forward ported the patch, see https://gerrit.libreoffice.org/#/c/19131/
However, it did not work. After the patch LibreOffice does not find a working JRE (neither Apple's, nor Oracle's).
Comment 7 Patrick (volunteer) 2015-10-04 20:14:09 UTC
Created attachment 119280 [details]
Patch to remove LibreOffice OS X code that conflicts with code changes in previous patch

I took at the forward ported files and one thing that I saw is that LibreOffice has an #elif MACOSX block that before the #else block that the NeoOffice patch added code to so I have attached a patch of the the forward ported jvmfwk/plugins/sunmajor/pluginlib/util.cxx file that removes the conflicting LibreOffice #elif.
Comment 8 Andras Timar 2015-10-04 22:27:03 UTC
(In reply to libreofficebugs from comment #7)
> Created attachment 119280 [details]
> Patch to remove LibreOffice OS X code that conflicts with code changes in
> previous patch
> 
> I took at the forward ported files and one thing that I saw is that
> LibreOffice has an #elif MACOSX block that before the #else block that the
> NeoOffice patch added code to so I have attached a patch of the the forward
> ported jvmfwk/plugins/sunmajor/pluginlib/util.cxx file that removes the
> conflicting LibreOffice #elif.

Thanks, with this LibreOffice finds Oracle JDK on 10.10, and it does not crash. However, Apple JRE on 10.9 is not found any more.
Comment 9 Patrick (volunteer) 2015-10-04 22:53:40 UTC
Unfortunately, that is one of the downsides of this patch. The NeoOffice 64 bit builds only support Oracle's Java so we didn't add any special code to allow Apple's Java on OS X 10.8 and 10.9.

If supporting Apple's Java on OS X 10.8 and 10.9 is necessary for LibreOffice, my first thought would be for you to add a Gestalt() call at the beginning of the JvmfwkUtil_isLoadableJVM() function in jvmfwk/plugins/sunmajor/pluginlib/util_cocoa.mm and return sal_True if running lower than OS X 10.10.
Comment 10 Stephan Bergmann 2015-10-05 10:13:52 UTC
I guess this is still the same issue as discussed in bug 74877 "OS X 10.9: abrupt exit of LO in JNI_CreateJavaVM w/ Oracle Java 7 and w/o Apple Java 6" (which pops up again each time a new version of OS X is released), i.e, Oracle still needs to get their JRE for OS X fixed.
Comment 11 Commit Notification 2015-11-04 09:30:53 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=32bc8ddbf335dd26019edcf12758643b4cff9913

tdf#94716 allow Oracle's JDK to be used on OS X 10.10 and 10.11

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Michael Meeks 2015-11-04 11:09:01 UTC
Whoot; good to see this merged - thanks Norbert ! =)
Comment 13 Michael Meeks 2015-11-04 11:09:40 UTC
(and of course thanks Patrick =).
Comment 14 Alex Thurgood 2015-11-09 11:34:42 UTC
(In reply to Commit Notification from comment #11)


> Affected users are encouraged to test the fix and report feedback.

The above commit now causes master to throw several repeated error messages about a missing or defective JDK on startup, even when my previous master builds functioned and detected without that error message my JDK 1.8.0_60u27
Comment 15 Alex Thurgood 2015-11-09 11:37:46 UTC
(In reply to Alex Thurgood from comment #14)
> (In reply to Commit Notification from comment #11)
> 
> 
> > Affected users are encouraged to test the fix and report feedback.
> 
> The above commit now causes master to throw several repeated error messages
> about a missing or defective JDK on startup, even when my previous master
> builds functioned and detected without that error message my JDK 1.8.0_60u27

Note that I have both AppleJava for OSX (1.6) and the Oracle JDK installed, as this was the only way to obtain a functional Java environment with LO up til now.
Comment 16 Stephan Bergmann 2015-11-09 11:50:52 UTC
(In reply to Alex Thurgood from comment #14)
> The above commit now causes master to throw several repeated error messages
> about a missing or defective JDK on startup, even when my previous master
> builds functioned and detected without that error message my JDK 1.8.0_60u27

I assume you mean "messages about a missing or defective *JRE*"?

And are you sure you had a JDK selected for use in LO previously, or merely a JRE?  (As, AFAIU, plain JRE installations are no longer accepted by LO now?)
Comment 17 Alex Thurgood 2015-11-09 12:38:59 UTC
(In reply to Stephan Bergmann from comment #16)
> (In reply to Alex Thurgood from comment #14)
> > The above commit now causes master to throw several repeated error messages
> > about a missing or defective JDK on startup, even when my previous master
> > builds functioned and detected without that error message my JDK 1.8.0_60u27
> 
> I assume you mean "messages about a missing or defective *JRE*"?
> 


Yes, the missing and/or defective JRE message.


> And are you sure you had a JDK selected for use in LO previously, or merely
> a JRE?  (As, AFAIU, plain JRE installations are no longer accepted by LO
> now?)

Well, it resides in 
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents
Comment 18 Alex Thurgood 2015-11-13 15:21:48 UTC
*** Bug 95774 has been marked as a duplicate of this bug. ***
Comment 19 Alex Thurgood 2016-05-18 07:49:46 UTC
*** Bug 99841 has been marked as a duplicate of this bug. ***
Comment 20 andriusr@yahoo.com 2016-07-28 14:31:33 UTC
I still having "LibreOffice requires a Java runtime environment (JRE)..." (like it is described in bug 99841) message on MaxOSX 10.9.5 when trying to run macro or use mission-critical extensions like Language Tools. 
Installed Oracle JDK 8.101 and Apple JDK 1.6, however, this did not help.
I think this bug needs to have highest priority since without Java many useful features does not work at all.
Comment 21 Julien Nabet 2016-07-28 14:40:51 UTC
(In reply to andriusr@yahoo.com from comment #20)
> I still having "LibreOffice requires a Java runtime environment (JRE)..."
> (like it is described in bug 99841) message on MaxOSX 10.9.5 when trying to
> run macro or use mission-critical extensions like Language Tools. 
> Installed Oracle JDK 8.101 and Apple JDK 1.6, however, this did not help.
> I think this bug needs to have highest priority since without Java many
> useful features does not work at all.

Try this:
1) purge any Java version with 
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.JavaUpdateHelper.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
(see http://stackoverflow.com/questions/19039752/removing-java-8-jdk-from-mac)
2) install last jdk from java website
3) remove LO profile
If you don't have the last stable LO version 5.1.4, uninstall any LO version and install 5.1.4 from official website
4) restart computer to be sure there's only last Java in RAM
5) start LO
In my case, Java wasn't detected automatically but if you go to Menu Options/Advanced and select Java then restart LO, it's ok.
(see https://bugs.documentfoundation.org/show_bug.cgi?id=101057#c15)

Of course, it's just a workaround I'd prefer Java would be detected automatically.
Comment 22 andriusr@yahoo.com 2016-07-28 15:02:23 UTC
Hi Julien,
I am using latest LO 5.1.4.2 .
There is note above, that patch does not work on MacOSX 10.9.5, and your instructions, as I can see are tested on 10.11.5. Does somethig changed since that message?
Just some extra information- I went to LO Preferences->Advanced and found one entry, Oracle Java, however, this entry was unselected.
I selected it and now instead of earlier message of unavailability of JRE I am having crash each time trying to run macro.
Comment 23 andriusr@yahoo.com 2016-07-28 15:44:49 UTC
Julien,
did all steps you suggested, however, I have crash of LO once I select Java in Advanced panel.
Comment 24 V Stuart Foote 2016-07-28 15:55:42 UTC
(In reply to andriusr@yahoo.com from comment #22)
> Hi Julien,
> I am using latest LO 5.1.4.2 .
> There is note above, that patch does not work on MacOSX 10.9.5, and your
> instructions, as I can see are tested on 10.11.5. Does somethig changed
> since that message?
> Just some extra information- I went to LO Preferences->Advanced and found
> one entry, Oracle Java, however, this entry was unselected.
> I selected it and now instead of earlier message of unavailability of JRE I
> am having crash each time trying to run macro.

Sorry it doesn't work on a 10.9.5 release. See comment 9

Also for users on 10.10 or 10.11, JDK builds > 99 patch has not been applied to the 5.1 branch. See bug 101057
Comment 25 andriusr@yahoo.com 2016-07-28 16:52:04 UTC
Tested with LO 5.3 alpha and it Java works there on my system, even with JDK build 102. Would be good to get all patches to the stable LO version.
Comment 26 andriusr@yahoo.com 2016-07-28 17:33:18 UTC
It works also with prelease version 5.1.5.2.
Comment 27 Alex Thurgood 2016-08-10 16:47:56 UTC
The more recent crashing wrt JDK 1.8.0_102 was fixed in bug 101057 by Caolan's commits :

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a3b3c5fcd7efd3e33a0f0078bd6fd23689c45c41

which has been backported to 5.1.x

If the problem still exists for 10.9.5, then we should amend the description/title
Comment 28 Alex Thurgood 2016-08-10 16:49:05 UTC
Or else close this bug as fixed, or WFM and open a new one with regard to 10.9.5
Comment 29 V Stuart Foote 2016-08-10 17:08:29 UTC
Close it.

Per comment 9 OS X 10.8 and 10.9 are not supported by the NeoOffice provided JDK based work around. Seems it could be adjusted, but why?

This remains up to Oracle to fix the JRE for use on OS X--and would not expect them to be interested in doing anything for 10.8, 10.9 or even 10.10 builds.

At some point when Oracle meets their responsibility to Apple, the NeoOffice provided JDK workaround will need to be backed out--see no advantage to jumping through hoops to make it work for 10.9 and earlier OS X.
Comment 30 Julien Nabet 2016-08-10 19:19:22 UTC
(In reply to V Stuart Foote from comment #29)
> Close it.
> 
> Per comment 9 OS X 10.8 and 10.9 are not supported by the NeoOffice provided
> JDK based work around. Seems it could be adjusted, but why?
> 
> This remains up to Oracle to fix the JRE for use on OS X--and would not
> expect them to be interested in doing anything for 10.8, 10.9 or even 10.10
> builds.
> 
> At some point when Oracle meets their responsibility to Apple, the NeoOffice
> provided JDK workaround will need to be backed out--see no advantage to
> jumping through hoops to make it work for 10.9 and earlier OS X.

I rarely test LO on MacOS and know very little about it but if it can't work on 10.8 and 10.9, what about changing prerequisites for 5.2 and putting 10.10?

Indeed, I don't know Apple support policies (I didn't find any official sources) but some responses on forums seem to indicate that only last stable + 2 previous versions would be supported (eg: http://apple.stackexchange.com/questions/212064/what-are-apples-update-and-end-of-life-policies-in-2015)
So since last stable one is 10.12 (Sierra), 10.10 should be ok.
Comment 31 Alex Thurgood 2016-09-07 07:23:49 UTC
Per comment 29, closing as fixed, thanks to Patrick Luby's patch. The bug title states that the problem was with regard to 10.10 and 10.11 and this has now been resolved.

If somebody wants to open a bug report for the same Java support issue with regard to 10.9 and 10.8, then I think we should allow that too, and not close it as won't fix, at least for as long as we are still building our release builds against the 10.8 SDK.

We should also bear in mind that in integrating this patch into trunk, we have alienated that small percentage of OSX users running OSX < 10.10 (I still have a 10.9 machine around, so am also directly affected by this problem).
Comment 32 Alex Thurgood 2016-09-07 07:25:25 UTC
*** Bug 101954 has been marked as a duplicate of this bug. ***
Comment 33 Alex Thurgood 2016-12-19 08:16:24 UTC
*** Bug 104765 has been marked as a duplicate of this bug. ***
Comment 34 cte39794 2016-12-19 14:51:31 UTC
LO 5.1.6.2

I'm not a coder.  Bug 94716 says this problem is fixed, but in the message tangle, I do not see a plain English fix.  I am certain that, on my LibreOffice 5.1.6.2, OS X Sierra Mac Book with no Java installed or Java 6 installed or Java 8 installed, the symptoms persist.
Comment 35 V Stuart Foote 2016-12-19 16:15:06 UTC
(In reply to cte39794 from comment #34)
> LO 5.1.6.2
> 
> I'm not a coder.  Bug 94716 says this problem is fixed, but in the message
> tangle, I do not see a plain English fix.  I am certain that, on my
> LibreOffice 5.1.6.2, OS X Sierra Mac Book with no Java installed or Java 6
> installed or Java 8 installed, the symptoms persist.

Let me make it plain--install a Java 8 JDK, not a JRE--!  

A JRE (Apple 1.6, or Oracle 1.8) will not work, you need the full JDK install (actually the JRE from the JDK) until Oracle corrects the Apple specific JNI calls and we can revert the LibreOffice code base to use the JRE.
Comment 36 cte39794 2016-12-19 18:04:58 UTC
I did that and, while creating a new base, still get the message:

"The connection to the data source "New Database22" could not be established.

The connection to the external source could not be established.  No SBDC driver was found for the URL 'sdbc:embedded:hsqldb'."

My response to that, honed over the past several days, is to quit LO base.  Then, reopen LO home, LibreOffice>Preferences>Advanced, check the "Use a Java runtime environment.", mark "Oracle Corporation 1.8.0_111", and "OK".  I then Quit LO and start anew to create a new base.

Now we have:

"LibreOffice Document Recovery

Due to an unexpected error, LibreOffice crashed.  All the files you were working on will now be saved.  The next time LibreOffice is launched, your files will be recovered automatically.

The following files will be recovered:"

I "OK".

Response is:

"LibreOffice Document Recovery

Press 'Start Recovery' to start the recovery process of the documents listed below.
Press 'Discard Recovery Data' to abandon attempting recovery of these documents.
The 'Status' column shows whether the document can be recovered.

Recovering document:

Status of recovered documents:
Document Name                     Status
New Database3                     Not Recovered Yet"

I 'Start Recovery'.

Now:

"LibreOffice Document Recovery

Recovery of your documents was finished.
Click 'Finish' to see your documents.

Recovering document:

Status of recovered documents:
Document Name                     Status
New Database3.ODB                 Successfully recovered"

I 'Finish'.

LO base screen for New Database 3 appears. I click on Tables.

"LibreOffice Document Recovery

Due to an unexpected error, LibreOffice crashed.  All the files you were working on will now be saved.  The next time LibreOffice is launched, your files will be recovered automatically.

The following files will be recovered:
New Database 3.odb"

I click OK.

"LibreOffice Document Recovery

Press 'Start Recovery' to start the recovery process of the documents listed below.
Press 'Discard Recovery Data' to abandon attempting recovery of these documents.
The 'Status' column shows whether the document can be recovered.

Recovering document:

Status of recovered documents:
Document Name                     Status
New Database3                     Not Recovered Yet"

I 'Start Recovery'.

Now:

"LibreOffice Document Recovery

Recovery of your documents was finished.
Click 'Finish' to see your documents.

Recovering document:

Status of recovered documents:
Document Name                     Status
New Database3.ODB                 Successfully recovered"

I 'Finish'.

Back to base LO screen for New Database3.ODB.  Click Tables...crash LO...begin recovery again.

There must be more if this is "fixed".
Comment 37 Stephan Bergmann 2016-12-20 08:05:25 UTC
(In reply to cte39794 from comment #34)
> LO 5.1.6.2

LO 5.1.6 unfortunately has yet another error causing problems (incl. potential crashes) when using a JDK with a micro version number >= 100 (like the 111 in your "Oracle Corporation 1.8.0_111").  That error was fixed for LO 5.1.5, but the fix got lost for 5.1.6, see bug 103719 comment 18 for details.
Comment 38 cte39794 2016-12-20 21:54:58 UTC
Thank you Stephan.  I moved to LO 5.2.3.3 and I was able to move my database from Windows to Sierra and use it.

The plain English answer, then to the LO/OS X database bug is:

Download and install the most recent Java JDK (not just the browser JRE).
Download and install the most recent LibreOffice (now 5.2.3.3).

The fix is in.