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

[PATCH] Fix JavaHL crash in RequestChannel.nativeRead

From: Alexandr Miloslavskiy <alexandr.miloslavskiy_at_syntevo.com>
Date: Mon, 10 Aug 2020 21:30:00 +0200

Please find test snippet and patch attached.

[[[
Fix JavaHL crash in RequestChannel.nativeRead

The problem here is that when 'RemoteSession' is destroyed, it also
does 'apr_pool_destroy()' which frees memory behind 'apr_file_t', which
is represented by 'TunnelChannel.nativeChannel' in Java.
'TunnelChannel' runs on a different thread and is unaware that
'apr_file_t' pointer is now invalid.

Fix this by informing 'TunnelChannel' before 'apr_file_t' is freed.

One other problem is that when 'TunnelAgent.openTunnel()' throws an
exception, 'OperationContext::closeTunnel()' was not called at all.

[in subversion/bindings/javahl]
* native/OperationContext.cpp
   (close_TunnelChannel): New function to inform Java side.
   (openTunnel): Keep references to Java tunnel objects.
   (openTunnel): In case of exception, clean up properly.
   (closeTunnel): Inform Java side when tunnel is closed.
* src/org/apache/subversion/javahl/util/RequestChannel.java
   Add 'synchronized' to avoid error described in 'syncClose()'
* src/org/apache/subversion/javahl/util/ResponseChannel.java
   Add 'synchronized' to avoid error described in 'syncClose()'
* src/org/apache/subversion/javahl/util/Tunnel.java
   A new function to clean up. I decided not to change old '.close()'
   because the new function can lead to a deadlock if used incorrectly.
]]]

Received on 2020-08-10 21:44:45 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.