‹ zgba 中国吧
EN
AOSP Source Releases Are So Late Developers Disassemble Libraries to Report Bugs

AOSP Source Releases Are So Late Developers Disassemble Libraries to Report Bugs

On Android 17 builds from September 2026, wcscspn() and wcspbrk() stop at the first character of the string that is >= U+0100 whenever the reject set has two or more characters that are all < U+0100. The character is reported as a match even though it is not in the set. wcsspn(), wcschr(), wcsrchr(), wmemchr() and wcsstr() are correct.

Any code that scans wide strings for ASCII delimiters, for example newline or wildcard characters, breaks as soon as the text contains an emoji, CJK, Cyrillic, Greek or Latin Extended character.

The public android17-release sources (android-17.0.0_r1, June 2026) build wcscspn/wcspbrk from external/llvm-libc, which is a plain nested loop over wchar_t and is correct. The code on the September builds is different (see “Mechanism”), so the regression was introduced between the June and September releases.

Build with the NDK (aarch64-linux-android30-clang), push to /data/local/tmp, run with adb shell:

Output on CP3A.260905.009:

A sweep of every code point from U+0001 to U+10FFFF (skipping surrogates and the two set members) with wcscspn(L”\n”, L”x\n”) returns 0 instead of 1 for 1,111,808 code points: every one from U+0100 to U+10FFFF. U+0001 to U+00FF are correct.

Which set shapes trigger it (all measured on the Pixel 8a):

Disassembly of wcscspn in /apex/com.android.runtime/lib64/bionic/libc.so on CP3A.260905.009 shows three paths selected by the set:

A character >= 0x100 cannot be in a set whose members are all < 0x100, so for wcscspn the scan must continue past it. The code stops instead. wcsspn has the same structure, and there stopping is the correct answer (the character is not in the keep set), which is why only the complement functions are wrong. wcspbrk is implemented on top of this scan and inherits the bug.

The existing bionic test TEST(wchar, wcspbrk) in tests/wchar_test.cpp only uses ASCII input, so it does not catch this. A test such as EXPECT_EQ(3u, wcscspn(L”aĀb\n”, L”x\n”)) would.

Visual Pinball on Android (libwinevbs, a Unix build of Wine’s vbscript engine) stopped loading any table whose VBScript source contains a comment with an emoji after the September update: the lexer uses wcspbrk(ptr, L”\n\r”) to skip comments, got the position of the first emoji instead of the line end, and reported “Invalid character”. FileSystem.MoveFolder likewise treated every path containing a character >= U+0100 as a wildcard pattern via wcspbrk(src, L”*?><”).

Worked around downstream by replacing the calls with plain loops: vpinball/libwinevbs#41 (shipped in vpinball/vpinball@e7837322f4).

Full disassembly of the affected functions and the probe sources are available on request.

yeah, that all sounds correct, and seems to still be an issue at ToT.

(i was going to say “you know you can just look at the source?”, but android-latest-release seems to still be too old to have any of these changes from april :-( )

wcspbrk() is affected because it’s just

but i’ll add both missing tests, and ideally try to see if i can find everywhere else we’re missing a test that actually uses non-ascii!

i’ll also see if i can get the fix backported to minimize the number of affected devices. (which is probably a reason to ensure any not-directly-related tests are added in a separate later change.)

gah, even more embarrassing is that we do have an existing test for wcscspn(), it’s just wrong:

Thanks for the quick response. It’s indeed unfortunate that the source is not available (yet).

Sorry if it sounds dramatic, because it’s not. I’m just worried. Something feels wrong with this…

Since Google decided to close AOSP source code, a lot of issues have been flourishing without any kind of fix, and there’s no transparency from the Google part…

Is there any movement regarding how this is going to be managed? I mean, not this bug, but the issues regarding the management of the AOSP project.

Is there any movement regarding how this is going to be managed? I mean, not this bug, but the issues regarding the management of the AOSP project.

source.android.com (in particular, https://source.android.com/docs/whatsnew/site-updates?year=2026#aosp-changes) has official communication on this topic.

(i was going to say “you know you can just look at the source?”, but android-latest-release seems to still be too old to have any of these changes from april :-( )

FWIW, android-latest-release is a manifest branch, and android17-release is the git branch. The android 17 sources for bionic are in https://android.googlesource.com/platform/bionic/+/refs/heads/android17-release.

Yes, but where is the source code for Android 17 QPR1 which is what is actually running on Pixel and has been stable for over a month…

There must be a better location to discuss these general issues?

Add Oct 14 tech news (incremental scan window 06:13-07:0x UTC Oct 14 …

  1. There must be a better location to discuss these general issues?

yeah, we are not the people who can help you with anything that can’t be fixed in code. but if anyone does have other libc issues or toolchain issues, please file them (as separate bugs!) so we can look at them.

in the meantime, in the spirit of https://sre.google/sre-book/postmortem-culture/ i’ll be making sure we add the missing test, fix the broken test, and run the tests against at least one other libc to make it harder to check in incorrect tests in future.

View original article