Commit fd5772c
fix(nsf): replace regex with isSha1Hex to eliminate ICU JNI crash
Repeated calls to Regex("^[0-9a-fA-F]{40}$").matches() in applyAuth()
allocate a new ICU MatcherNative_matchesImpl invocation on every poll
cycle (2× per 60 s = ~120/hour). On Samsung Galaxy S24 FE / Android 15
with Scudo+MTE enabled, the jintArray chunk header used by
ReleaseIntArrayElements becomes corrupted after many poll cycles (~73
minutes in observed logs), triggering a SIGABRT that kills the app.
Crash signature (Samsung SM-S721B, Android 15, AP3A.240905.015.A2):
Scudo ERROR: corrupted chunk header
#5 scudo::Allocator::deallocate
#6 JNI::ReleasePrimitiveArray<jintArray>
#7 CheckJNI::ReleasePrimitiveArrayElements
#8 MatcherNative_matchesImpl (libicu_jni.so)
thread: NightscoutFollower-<serial>
Fix: replace the regex with isSha1Hex(), a pure Kotlin char scan that is
semantically equivalent but makes no ICU JNI calls. Returns true iff the
string is exactly 40 characters of [0-9a-fA-F].
Adds edge-case tests: lowercase, uppercase, mixed-case SHA1 hex, 39-char,
and 40-char non-hex (contains 'g').
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 6ed33d3 commit fd5772c
2 files changed
Lines changed: 44 additions & 4 deletions
File tree
- Common/src
- main/java/tk/glucodata/drivers/nightscout
- test/java/tk/glucodata/drivers/nightscout
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
| |||
Lines changed: 34 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 52 | + | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
60 | 91 | | |
61 | 92 | | |
62 | 93 | | |
| |||
0 commit comments