termux / termux/termux-api

termux-toast crashes process

Open Beginner friendly
#272 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Problem description
Calling termux-toast will crash the process (Android 8.1, Resurrection Remix 6.2)

Steps to reproduce

  1. termux-toast abc
  2. Termux:API will stop working. Then any API command like termux-battery-status will hang and log "process is bad".

Expected behavior
Showing a toast

Additional information

Post output of command termux-info.

Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/grimler/science-packages-21 science/stable
https://dl.bintray.com/grimler/game-packages-21 games/stable
https://termux.net stable/main
https://termux.net stable/main
System information:
Linux localhost 4.4.169-Chihayafuru-v0.60 #1 SMP PREEMPT Sun Jan 13 16:15:40 UTC 2019 aarch64 Android
Termux-packages arch:
aarch64
Android version:
8.1.0
Device manufacturer:
HUAWEI
Device model:
FRD-AL00

If you are rooted or have access to adb then capture a logcat with logcat -d "*:W", from a adb or root shell.

--------- beginning of crash
06-24 15:37:33.696  6306  6306 E AndroidRuntime: FATAL EXCEPTION: main
06-24 15:37:33.696  6306  6306 E AndroidRuntime: Process: com.termux.api, PID: 6306
06-24 15:37:33.696  6306  6306 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setTint(int)' on a null object reference
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.termux.api.ToastAPI$1.lambda$writeResult$0$ToastAPI$1(ToastAPI.java:36)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.termux.api.-$$Lambda$ToastAPI$1$fiyVytqeopW7wtBFP8RqXEm_m7w.run(Unknown Source:12)06-24 15:37:33.696  6306  6306 E AndroidRuntime:
                                                        at android.os.Handler.handleCallback(Handler.java:790)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6499)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I suggest adding checks for background and textView here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ToastAPI.java at line 36, where the logcat shows a NullPointerException while setting a Drawable tint. Reproduce with termux-toast abc on the reported setup, then verify that the command shows a toast without crashing Termux:API and that a subsequent API command such as termux-battery-status does not hang.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.