Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV on switching context #21

Closed
think-android opened this issue Oct 29, 2014 · 9 comments
Closed

SIGSEGV on switching context #21

think-android opened this issue Oct 29, 2014 · 9 comments

Comments

@think-android
Copy link

SuperSU v2.16
RootTool v3.5
Nexus 7 with Android 5.0, patched kernel (from Chainfire)

D/RootTools v3.5( 3069): Context is different than open shell, switching context...
D/RootTools v3.5( 3069): Starting Root Shell!
D/RootTools v3.5( 3069): Starting shell: su
D/RootTools v3.5( 3069): Context: u:r:system_app:s0
D/RootTools v3.5( 3069): Timeout: 25000
D/RootTools v3.5( 3069): Closing shell
D/RootTools v3.5( 3069): Read all output
D/RootTools v3.5( 3069): Shell destroyed
--------- beginning of crash
F/libc ( 3259): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 3259 (daemonsu)
E/ ( 183): ptrace attach failed: Permission denied
W/System.err( 3069): com.stericson.RootTools.exceptions.RootDeniedException: Root Access Denied
W/System.err( 3069): at com.stericson.RootTools.execution.Shell.(Shell.java:168)
W/System.err( 3069): at com.stericson.RootTools.execution.Shell.startRootShell(Shell.java:558)
W/System.err( 3069): at com.stericson.RootTools.execution.Shell.switchRootShellContext(Shell.java:626)
W/System.err( 3069): at com.stericson.RootTools.execution.Shell.startRootShell(Shell.java:570)
W/System.err( 3069): at com.stericson.RootTools.RootTools.getShell(RootTools.java:376)
W/System.err( 3069): at com.stericson.RootTools.RootTools.getShell(RootTools.java:393)
W/System.err( 3069): at com.think_android.apps.appmonster.base.service.RootUninstallIntentService.silentUninstall(RootUninstallIntentService.java:99)
W/System.err( 3069): at com.think_android.apps.appmonster.base.service.RootUninstallIntentService.handleActionUninstallApp(RootUninstallIntentService.java:58)
W/System.err( 3069): at com.think_android.apps.appmonster.base.service.RootUninstallIntentService.onHandleIntent(RootUninstallIntentService.java:51)
W/System.err( 3069): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
W/System.err( 3069): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 3069): at android.os.Looper.loop(Looper.java:135)
W/System.err( 3069): at android.os.HandlerThread.run(HandlerThread.java:61)

@Stericson
Copy link
Owner

This looks like an issue with Root.

Make sure that the following is true:

  1. Root is properly configured on your device.
  2. You are granting Root permission to your application

If the above doesn't work, there may still be an issue with root on your device.

  1. Try re-rooting your phone, did this resolve the issue?

If non of the above help can you provide me with the code that is causing the issue?

@think-android
Copy link
Author

Hi there, thanks a lot for your answer.

The code try to do "pm uninstall ...".

It does work in the shell, SuperSU pop up for access and so on:
su --context u:r:system_app:s0 -c "pm uninstall com.example.app" < /dev/null

The app is listed in superSU as well, as allowed. But it crash somethere. I'm trying to get the SuperSU logs to see what command will be fire at the end.

I post my code later (have to boot my other PC).

@think-android
Copy link
Author

This is the part:

Command command = new Command(0, false, "pm uninstall " + packageName) {
@OverRide
public void commandCompleted(int arg0, int arg1) {
}

        @Override
        public void commandOutput(int arg0, String arg1) {
            Log.d("LOG_TAG",arg1);
            if (arg1.toLowerCase(Locale.US).contains(String.valueOf("Failure").toLowerCase(Locale.US))
                    || arg1.toLowerCase(Locale.US).contains(String.valueOf("Error").toLowerCase(Locale.US))
                    || arg1.toLowerCase(Locale.US).contains(String.valueOf("denied").toLowerCase(Locale.US))
                ) {
                try {
                    throw new Exception(arg1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                Notification.Builder errorBuilder = new Notification.Builder(RootUninstallIntentService.this);
                errorBuilder.setContentTitle(appLabel)
                        .setAutoCancel(true)
                        .setContentIntent(PendingIntent.getActivity(RootUninstallIntentService.this, 0, new Intent(), 0))
                        .setContentText(arg1)
                        .setColor(getResources().getColor(R.color.primary))
                        .setSmallIcon(R.drawable.noti_icon);
                mNotifyManager.notify(Common.NOTI_ID_RESTORE_ERROR + ((Long) System.currentTimeMillis()).intValue(), errorBuilder.build());
            }
        }

        @Override
        public void commandTerminated(int arg0, String arg1) {
        }
    };
    synchronized (command) {
        try {
            RootTools.debugMode=true;
            Shell shell = RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP);
            shell.add(command);
            command.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (RootDeniedException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

@think-android
Copy link
Author

One thing I forget, the code will be call from a IntentService.

@think-android
Copy link
Author

So, I got SuperSU PRO and can provide more logs now.

This code:

    Command command = new Command(0, "pm uninstall " + packageName)
    {
        @Override
        public void commandOutput(int id, String line) {
            Log.d("######## ", line);
        }

        @Override
        public void commandTerminated(int id, String reason) {

        }

        @Override
        public void commandCompleted(int id, int exitCode) {

        }
    };
    try {
        RootTools.getShell(true).add(command);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (TimeoutException e) {
        e.printStackTrace();
    } catch (RootDeniedException e) {
        e.printStackTrace();
    }

got this superSU logs:

screenshot_2014-11-03-12-16-33

if I change
RootTools.getShell(true).add(command);
to
RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);

SuperSU says:
screenshot_2014-11-03-12-16-39

@think-android
Copy link
Author

So, I've got your code and did some debug.

the code:
RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);

Shell.java / Worker class:
.......
if (line == null) {
throw new EOFException();
}
.......
the EOFException will be fired, so it seems line==null

@Stericson
Copy link
Owner

Let me do some testing on this....I'll reach back out to you...

@think-android
Copy link
Author

Thank you very much. If you need more info or logs or whatever, just tell a word.

@Stericson
Copy link
Owner

Can you try this new version?

https://drive.google.com/file/d/0B5Amguus3csDQW1zV04waEhXNkE/view?usp=sharing

Let me know if you see the same issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants