[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

JavaHL crash in finalize method if dispose called

From: Mark Phippard <markphip_at_gmail.com>
Date: Tue, 19 Apr 2011 09:18:59 -0400

In getting 1.7 to work with Subclipse I ran into some problems where
it seems that JavaHL does not have the same thread-safety that
previous versions had. Bert seemed to indicate that what was working
in earlier versions was probably just luck. In current Subclipse
versions, I construct one, and only one, SVNClient object and use it
from all threads. Fortunately, I have a boolean in place where I can
simply say that SVNClient is not threadsafe and this changes the
behavior of Subclipse so that instead constructs a new SVNClient
object for each usage. When I made this change, all works fine.

However, one reason I went to the single object approach a long time
ago was that I learned that the SVNClient.dispose() method should be
called when you are done with the object so that the native resources
can be freed. The way Subclipse was architected this was going to be
difficult to do, so I went with the single object approach.

Since it seemed that I was going to need to go back to having multiple
objects, I figured that I needed to fix this issue of not calling
dispose(). So I went through all of Subclipse and made this change as
needed so that the resources are cleaned up. But now I am finding
that I get crashes. What it looks to me is happening, is that when I
call dispose JavaHL is cleaning up its resources properly. However,
when the JVM later comes along and calls the finalize() method on the
objects as they are GC'd then JavaHL crashes in the finalize code.
Probably because it tries to free something that dispose already
freed. Here is the stacktrace I get from the crash:

Thread 8 Crashed: Java: Finalizer
0 libsvnjavahl-1.0.dylib 0x000000012011ae61
SVNBase::findCppAddrForJObject(_jobject*, _jfieldID**, char const*) +
119 (SVNBase.cpp:67)
1 libsvnjavahl-1.0.dylib 0x0000000120121781
SVNClient::getCppObject(_jobject*) + 35 (SVNClient.cpp:85)
2 libsvnjavahl-1.0.dylib 0x000000012013146e
Java_org_apache_subversion_javahl_SVNClient_finalize + 97

Is this fixable? Should I just skip calling dispose and let the
finalize method take care of it? I think you are not supposed to rely
on that method being called as the JVM does not make promises to call

Mark Phippard
Received on 2011-04-19 15:19:49 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.