Buggy code:
public class SyncthingRunnable implements Runnable { private static final String TAG = "SyncthingRunnable" ; private static final String TAG_NATIVE = "SyncthingNativeCode" ; private static final String TAG_NICE = "SyncthingRunnableIoNice" ; private static final String TAG_KILL = "SyncthingRunnableKill" ; public static final String UNIT_TEST_PATH = "was<seq2seq4repair_space>running" ; private static final AtomicReference < Process > mSyncthing = new AtomicReference < > ( ) ; private final Context mContext ; private String mSyncthingBinary ; private String [ ] mCommand ; public enum Command { generate , main , reset ; } public SyncthingRunnable ( Context context , SyncthingRunnable . Command command ) { } public SyncthingRunnable ( Context context , String [ ] manualCommand ) { } @ Override public void run ( ) { SharedPreferences sp = PreferenceManager . getDefaultSharedPreferences ( mContext ) ; int ret = 1 ; try { <START_BUG> ProcessBuilder pb = new ProcessBuilder ( "chmod" , "+x" , mSyncthingBinary ) ; <END_BUG> Process p = pb . start ( ) ; p . waitFor ( ) ; } catch ( IOException | InterruptedException e ) { Log . w ( SyncthingRunnable . TAG , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>chmod<seq2seq4repair_space>Syncthing" , e ) ; } Process process = null ; try { do { ProcessBuilder pb = ( useRoot ( ) ) ? new ProcessBuilder ( "su" , "-c" , TextUtils . join ( "<seq2seq4repair_space>" , mCommand ) ) : new ProcessBuilder ( mCommand ) ; Map < String , String > env = pb . environment ( ) ; env . put ( "HOME" , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) ) ; env . put ( "STTRACE" , sp . getString ( "sttrace" , "" ) ) ; env . put ( "STNORESTART" , "1" ) ; env . put ( "STNOUPGRADE" , "1" ) ; env . put ( "STGUIAUTH" , ( ( ( sp . getString ( "gui_user" , "" ) ) + ":" ) + ( sp . getString ( "gui_password" , "" ) ) ) ) ; process = pb . start ( ) ; SyncthingRunnable . mSyncthing . set ( process ) ; Thread lInfo = log ( process . getInputStream ( ) , INFO ) ; Thread lWarn = log ( process . getErrorStream ( ) , WARN ) ; niceSyncthing ( ) ; ret = process . waitFor ( ) ; SyncthingRunnable . mSyncthing . set ( null ) ; lInfo . join ( ) ; lWarn . join ( ) ; if ( ret == 3 ) { Log . i ( SyncthingRunnable . TAG , "Restarting<seq2seq4repair_space>syncthing" ) ; mContext . startService ( new android . content . Intent ( mContext , SyncthingService . class ) . setAction ( ACTION_RESTART ) ) ; } } while ( ret == 3 ) ; } catch ( IOException | InterruptedException e ) { Log . e ( SyncthingRunnable . TAG , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>execute<seq2seq4repair_space>syncthing<seq2seq4repair_space>binary<seq2seq4repair_space>or<seq2seq4repair_space>read<seq2seq4repair_space>output" , e ) ; } finally { if ( process != null ) process . destroy ( ) ; if ( ret != 0 ) { Log . e ( SyncthingRunnable . TAG_NATIVE , ( "Syncthing<seq2seq4repair_space>binary<seq2seq4repair_space>crashed<seq2seq4repair_space>with<seq2seq4repair_space>error<seq2seq4repair_space>code<seq2seq4repair_space>" + ( Integer . toString ( ret ) ) ) ) ; } } } private boolean useRoot ( ) { } private void niceSyncthing ( ) { } public void killSyncthing ( ) { } private static void killProcessId ( String id , boolean force ) { } private Thread log ( final InputStream is , final int priority ) { } }

Fix:
ProcessBuilder pb = new ProcessBuilder ( "chmod" , "500" , mSyncthingBinary ) ;