Thursday, December 01, 2011

5.0 amd64 K43U: Davmail crash with java dumping core, FreeBSD's package might be the saviour.


As some of you know, I'm using OpenBSD primarily for work and I use my company's email address which uses MS OWA. So I use davmail so Thunderbird can retrieve my emails properly. You can search my blog for davmail settings.

I downloaded davmail-3.9.6 and I noticed that less than an 1, davmail will crash and there's java.core dumping. I have a hint that this might be due to 64 version of davmail is not available for OpenBSD and there's only linux's version which has 64-bit.

As this issue is critical, I need to make sure I resolve this as soon as possible. Downloading linux's 64-bit version is out of the question because I don't want any more mess. So I thought of doing an experiment.

I noticed that FreeBSD have amd64 version of davmail in their package system. FreeBSD, which used to be i386 system only have broaden their supported architecture by releasing amd64 version of their OS a few years back. Good news indeed.

I found davmail-3.8.4 package (*.tgz) for FreeBSD 8.2 which is ok as long as it will work. I do some comparison and found that this is what's needed for davmail to work. No installation needed.


There's some files inside the lib folder and only 1-2 files has changed since 3.8.4 to 3.9.6. So I extracted the *.tgz and copied that files into ~/davmail/. Using my previous davmail configuration, I'm now using the amd64 version of davmail meant for FreeBSD.

I'm just using it today, starting in just 1 hour and so far it seems to be working fine. It davmail can survive working hours today then it's great. For the package, you can download from FreeBSD or I can provide mine if needed.

Update!: Just as I published this post, the davmail crashed again. Here's the header of the error message:

# A fatal error has been detected by the Java Runtime Environment:
# java.lang.OutOfMemoryError: requested 4361696 bytes for Chunk::new. Out of swap space?
# Internal Error (allocation.cpp:272), pid=11064, tid=8626964480
# Error: Chunk::new
# JRE version: 7.0
# Java VM: OpenJDK 64-Bit Server VM (20.0-b03 mixed mode bsd-amd64 compressed oops)
# If you would like to submit a bug report, please visit:

Maybe it's java's issue. Hmm. I'll need to search for answers. Maybe install another version of jre or jdk. Anyone else have this issue?

Update 02/12/11 09:40:
I found that there's already a few 5.0 users which posted question regarding this java.lang.OutOfMemoryError issue and it affected different java based program like eclipse and netbeans.

Rewinding a bit, DavMail is run using script which resides in DavMail folder. Normally by default, the script contains:

# Ahmad Zulkarnain 2011
BASE=`dirname $0`
for i in $BASE/lib/*; do export CLASSPATH=$CLASSPATH:$i; done
java -cp $BASE/davmail.jar:$CLASSPATH davmail.DavGateway $1

The last line tells the script to run DavMail. I tried to change the command to:

java -Xms512m -Xmx512m -cp $BASE/davmail.jar:$CLASSPATH davmail.DavGateway $1

Note the bold text are the changes I made. But then I have this error:

/home/karl/davmail/ /home/karl/davmail/davmail.conf
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I even tried using only -Xms512m or -Xmx512m with the same error. So then after reading the java man page, I experiment with adding -d64 to force DavMail to run in 64-bit environment. So now the last line of looks like this:

java -d64 -cp $BASE/davmail.jar:$CLASSPATH davmail.DavGateway $1

Now I tested that one invoking sh ~/davmail/ ~/davmail/davmail.conf without making it a background process so I can see the output in xterm. I tested that since my last post on the java.lang.OutOfMemoryError until the end of my working hour and there's no crash. *Maybe* DavMail is not stressed enough by then because mails are less in the evening. So today I'm testing the altered to see if it can survive until the end of my working hours. I will keep you guys posted on that.

Thanks to Daniel M for your comment, sorry I have to answer your question in here instead of the comment box but I'm still interested to know any java tips from you.

Update 02/12/11 11:49:
Ok it crashed again. Still have the java.lang.OutOfMemoryError and java.core dump. But at least it's not as fast as yesterday. I managed to get more than an hour of emailing done. So I need to search for more answers. Later.


Daniel M said...

I’m not familiar with DavMail, but am somewhat familiar with the JRE on OpenBSD. That said, how are you starting DavMail? Are you using –Xms or –Xmx on the command line?

Karl said...

Daniel M,

There's a script that contains the command to start davmail. By default it's just "java -cp davmail.jar". I will post update on it later. If I use -Xms and/or -Xmx davmail refuses to start. Currently I'm using "-d64" and it *seems* to be ok for until the end of my working hour yesterday. Thanks for the comment! I'll update the post later.