[stbsp_sprintf] "%s/%s" crash on armeabi-v7a (32bits) devices, arm64-v8a devices are fine.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 15/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- mobile-dev, tooling
Research direction
The crash is a SIGBUS in stbsp_vsprintfcb, reached from stbsp_sprintf, in the single header stb_sprintf.h. Start from the backtrace, then build the repro for armeabi-v7a with -O3 and compare it against the -O0 build, which works. Done means the "%s/%s" call returns "hello/world" on the 32-bit ARM release build without a fault. The issue does not say what to change, so confirm the cause first.
Written by the indexing model from the issue text.
Description
armeabi-v7a (32bits), debug build (-O0), ok
armeabi-v7a (32bits), release build (-O3), crash
arm64-v8a (64bits), debug build (-O0), ok
arm64-v8a (64bits), release build (-O3), ok
build env:
gradle 4.6
android-ndk-r20b-x86_64
armeabi-v7a
test code:
// quick test
{
const char *a = "hello";
const char *b = "world";
logw("a=%s", a);
logw("b=%s", b);
char buf[0x20] = { 0 };
stbsp_sprintf(buf, "%s/%s", a, b); // <---- crash on this line
logw("result:%s", buf);
}
output:
W/jni (11770): a=hello
W/jni (11770): b=world
F/libc (11770): Fatal signal 7 (SIGBUS) at 0x7a0d1497 (code=1), thread 11770 (main)
D/AEE/AED ( 147): $===AEE===AEE===AEE===$
stack backtrace:
I/DEBUG (11806): signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 7a0d1497
D/KeyguardViewMediator( 875): setHidden false
D/KeyguardUpdateMonitor( 875): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 875): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator( 875): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator( 875): handleMessage exit msg name=SET_HIDDEN
I/SurfaceFlinger( 153): [virtual void android::LayerScreenshot::setGeometry(const android::sp<const android::DisplayDevice>&, android::HWComposer::HWCLayerInterface&)] add:716, count:1
D/SurfaceFlinger( 153): [doDisplayComposition] skip composition for [Built-in Screen (type:0)], dirtyRegion empty
I/SurfaceFlinger( 153): [virtual void android::LayerScreenshot::setGeometry(const android::sp<const android::DisplayDevice>&, android::HWComposer::HWCLayerInterface&)] add:716, count:1
D/SurfaceFlinger( 153): [doDisplayComposition] skip composition for [Built-in Screen (type:0)], dirtyRegion empty
I/DEBUG (11806): r0 bee42100 r1 7a0d1497 r2 00000005 r3 00000004
I/DEBUG (11806): r4 00000005 r5 00000000 r6 bee42100 r7 bee420c0
I/DEBUG (11806): r8 00000000 r9 bee42100 sl 00000005 fp 00000005
I/DEBUG (11806): ip 00000000 sp bee41e08 lr 00000020 pc 7a02a692 cpsr 20000030
I/DEBUG (11806):
I/DEBUG (11806): backtrace:
I/DEBUG (11806): #00 pc 00311692 /data/app-lib/com.company.app-2/libGL2JNI.so (stbsp_vsprintfcb+4817)
I/DEBUG (11806): nothings/stb#1 pc 00312219 /data/app-lib/com.company.app-2/libGL2JNI.so (stbsp_sprintf+40)
I/DEBUG (11806): nothings/stb#2 pc 001ed7db /data/app-lib/com.company.app-2/libGL2JNI.so (app::AppImpl::Init(char const*, char const*, char const*)+98)
I/DEBUG (11806): nothings/stb#3 pc 002382d9 /data/app-lib/com.company.app-2/libGL2JNI.so (Java_com_company_app_GL2JNILib_nativeOnActivityCreate+172)
I/DEBUG (11806):
I/DEBUG (11806): stack:
I/DEBUG (11806): bee41dc8 00000000
I/DEBUG (11806): bee41dcc 78f7a558
I/DEBUG (11806): bee41dd0 40145d60 /system/lib/libc.so
I/DEBUG (11806): bee41dd4 7a273000
I/DEBUG (11806): bee41dd8 40145d50 /system/lib/libc.so
I/DEBUG (11806): bee41ddc 400f59a0 /system/lib/libc.so (_pthread_internal_add+20)
I/DEBUG (11806): bee41de0 78f7a558
I/DEBUG (11806): bee41de4 400f5a60 /system/lib/libc.so (_init_thread+128)
I/DEBUG (11806): bee41de8 00004022
I/DEBUG (11806): bee41dec 4010f4e4 /system/lib/libc.so (mmap+92)
I/DEBUG (11806): bee41df0 40152af8
I/DEBUG (11806): bee41df4 7a372f00 [stack:11805]
- Dominant language
- C
- Stars
- 18
- Forks
- 5
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nothings/stb_sprintf
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nothings/stb_sprintf#10 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nothings/stb_sprintf#8 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nothings/stb_sprintf#5 ·
-
[SECURITY] stbsp_snprintf with count=0 writes null terminator before bufferPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nothings/stb_sprintf#4 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
nothings/stb_sprintf#20 ·
All issues in nothings/stb_sprintf
Similar issues
-
bug severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AlessandroSangiuliano/Uros#1014 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
OpenXiangShan/NEMU#1314 ·
Maintainers usually reply within 1 day
-
`get_options()` repeats the first byte when hex-encoding octet stringsPossibly taken @rue19 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
OpenPrinting/cups#1830 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
micropython/micropython#20020 ·
Maintainers usually reply within 1 day