Android cannot edit synced text files "resource acquired but never released"


(Sjdennis) #1

I have an Ubuntu laptop and an Android tablet, syncing a folder read/write both ways. The folder contains text files.

If I create a text file on Ubuntu, and it is synced to the Android tablet, I can open it, but cannot save it (overwriting the original) from any text editor. On attempting to save, I get the error "java.io.IOException: write failed: EBADF (Bad file descriptor). I have tried this from two separate text editors (QuickEdit and Turbo Editor).

However, I can:

  • Create new text files on the Android device and save into the synced folder.
  • Open a file that was created in Ubuntu, and save as a different file, with any Android text editor.
  • Update a “todo.txt” file with SimpleTask on the Android device - this works with no problems. But the same file cannot be updated using a text editor.
  • Create a file on Android, edit it on Ubuntu, then re-edit it on Android. As long as a file was created on Android it seems to work fine forever.

The issue appears to be that files added from Ubuntu are “acquired at attached stack trace but never released”, so cannot be accessed properly using java. See error log below.

Is there a simple way for me to get this working, or is it a bug?

Laptop: Syncthing v0.14.52, Ubuntu 16.04.5 LTS

Tablet: Syncthing v0.14.51, Syncthing-Android Version 0.10.15 (installed today from the Play Store), Android 7.0, Kernel 4.4.22, Lenovo Tablet TB-7304F

Settings: Ubuntu device is set to version track, Android device does not use version tracking. Android has “ignore permissions” set to “Yes”.

Thankyou, Samuel

11-27 14:54:39.155 E/StrictMode( 4335): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
11-27 14:54:39.155 E/StrictMode( 4335): java.lang.Throwable: Explicit termination method 'close' not called
11-27 14:54:39.155 E/StrictMode( 4335): 	at dalvik.system.CloseGuard.open(CloseGuard.java:180)
11-27 14:54:39.155 E/StrictMode( 4335): 	at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:103)
11-27 14:54:39.155 E/StrictMode( 4335): 	at java.net.Socket.createImpl(Socket.java:464)
11-27 14:54:39.155 E/StrictMode( 4335): 	at java.net.Socket.getImpl(Socket.java:530)
11-27 14:54:39.155 E/StrictMode( 4335): 	at java.net.Socket.setSoSndTimeout(Socket.java:1194)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.Connection.setTimeouts(Connection.java:508)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:400)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:356)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:273)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:478)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:426)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
11-27 14:54:39.155 E/StrictMode( 4335): 	at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)

(Sjdennis) #2

I have now connected a third device, an Android phone. All three devices are syncing to each other. This issue does not occur on the phone. It only occurs on my tablet, as outlined above.

However, after adding the phone, the behaviour changed slightly. Now:

  • All old files that were misbehaving as described above still misbehave. But
  • New files added from Ubuntu can now be edited on the tablet. However
  • New files added from the phone cannot be edited on the tablet.

That’s just weird, and I don’t know where to start with troubleshooting it. I need to be able to reliably edit files on the tablet, it’s my mobile workstation.

Error messages look identical to those posted above.


(Audrius Butkevicius) #3

Honestly, no idea. The exception looks like a network exception, not related to files. I’d check permissions of the file.


(Sjdennis) #4

I was concerned that nobody would have any idea! :slight_smile: It is a weird one.

I have used Termux to navigate to the file directory and use ls -l to check permissions. Every file has identical permissions, there is no difference between files that edit correctly and files that do not:

-rw-rw---- 1 root everybod size datetime filename

Will Termux give the correct information, or should I check this elsewhere? Can you think of any other properties of the files I could check?


(Sjdennis) #5

I have now tested this with syncthing-fork on the tablet instead (Syncthing v0.14.52, Syncthing-fork v0.14.52.1). I have the same errors as above.

Thanks to @Catfriend1 for the suggestion, unfortunately it didn’t resolve this particular issue.


(Sjdennis) #6

Problem solved, sort-of. I think it is a Java issue. After experimenting with a lot more text editors, some work and some don’t. Quoda for instance can update these files fine - and once edited with Quoda, then QuickEdit and Turbo Editor can now update them also.

I do believe that Syncthing is introducing the issue in the first place, as I have only observed it on files synced with Syncthing to this tablet from another device. However, it’s no longer a critical matter since it’s only specific to certain editors.

Thankyou everyone who’s read and pondered this even if you couldn’t think of anything to suggest! Consider the issue closed.


(Catfriend1) #7

Thanks for your feedback on this. Maybe we can some day put a recommended editor that’s foss as a link into the UI.