Skip to content

Commit dab2631

Browse files
minaripenguinRakeshBatra
authored andcommitted
libs: hwui: Avoid system crash if font contains invalid/null font data
* i thought this was fixed by dropping HB and freetype modifications but a user reported a sysui crash without logcat nor context so im using my old copy * addr2line was pointing the NPD [1] to a new instance of SkMemoryStream (if im not mistaken) minaripenguin@minaripenguin:~/bugreport-oriole-TQ2A.230405.003.E1-2023-04-13-09-02-17/FS/data/tombstones$ addr2line -f -e '/mnt/xxxx/xxxxx/out/target/product/oriole/system/lib/libhwui.so' 000000000024a61c _ZN14SkMemoryStreamC2E5sk_spI6SkDataE * to temporarily aid the crash issue, until we find and fix the font that causes the crash, silently swallow the errors since the rom shouldn't booting at all if current font in use has invalid data. [1] *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** RisingOS Version: '1.0-20230412-UNOFFICIAL-oriole' Build fingerprint: 'google/oriole/oriole:13/TQ2A.230305.008.E1/9677224:user/release-keys' Revision: 'MP1.0' ABI: 'arm64' Timestamp: 2023-04-13 00:41:15.026955853+0800 Process uptime: 216s Cmdline: com.android.systemui pid: 17576, tid: 17613, name: RenderThread >>> com.android.systemui <<< uid: 10403 tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE) signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000010 Cause: null pointer dereference x0 b4000074cc5b7e60 x1 00000072ca63fa20 x2 00000072ca63fa20 x3 0000000000000001 x4 00000072ca63efa0 x5 000000747c59e4bc x6 00005a120000edab x7 0000906f00008280 x8 0000000000000000 x9 56bd015d3f6fc8f6 x10 0000000000000000 x11 000000000000001a x12 0000000000000000 x13 b4000074ecbba980 x14 0000000000000033 x15 0000000000000019 x16 00000075f74ae6a8 x17 00000075fdb0fec0 x18 00000072ca470000 x19 b4000074cc5b7e60 x20 b4000074cc5b7e88 x21 b4000074cc5b7e60 x22 b40000737c76ae48 x23 b40000737c76ae30 x24 7ffffffffffffff8 x25 1fffffffffffffff x26 00000000ffffffff x27 b4000073cc52f898 x28 00000072ca547000 x29 00000072ca63f7e0 lr 00000075eec487e0 sp 00000072ca63f7e0 pc 00000075eec4a61c pst 0000000020001000 backtrace: #00 pc 000000000024a61c /system/lib64/libhwui.so (android::uirenderer::AnimatorManager::pushStaging()+108) (BuildId: f37109e40765e94e2634e351e2ba0981) #1 pc 00000000002487dc /system/lib64/libhwui.so (android::uirenderer::AnimationContext::runRemainingAnimations(android::uirenderer::TreeInfo&)+44) (BuildId: f37109e40765e94e2634e351e2ba0981) #2 pc 000000000025b2a4 /system/lib64/libhwui.so (android::uirenderer::AnimationContextBridge::runRemainingAnimations(android::uirenderer::TreeInfo&)+36) (BuildId: f37109e40765e94e2634e351e2ba0981) #3 pc 000000000027fdcc /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::prepareTree(android::uirenderer::TreeInfo&, long*, long, android::uirenderer::RenderNode*)+348) (BuildId: f37109e40765e94e2634e351e2ba0981) #4 pc 0000000000282bdc /system/lib64/libhwui.so (std::__1::__function::__func<android::uirenderer::renderthread::DrawFrameTask::postAndWait()::$_0, std::__1::allocator<android::uirenderer::renderthread::DrawFrameTask::postAndWait()::$_0>, void ()>::operator()() (.c1671e787f244890c877724752face20)+364) (BuildId: f37109e40765e94e2634e351e2ba0981) #5 pc 0000000000272c34 /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+580) (BuildId: f37109e40765e94e2634e351e2ba0981) #6 pc 0000000000292e9c /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+412) (BuildId: f37109e40765e94e2634e351e2ba0981) #07 pc 0000000000013220 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+416) (BuildId: 536947a6fb111c99b28090cdd95ee772) #08 pc 00000000000bc1cc /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+204) (BuildId: 7c802f36645db769f96376c94049c9cf) #09 pc 0000000000055020 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 7c802f36645db769f96376c94049c9cf) Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com> Signed-off-by: RakeshBatra <raakesh.batra@rediffmail.com>
1 parent c143385 commit dab2631

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

libs/hwui/jni/FontFamily.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ static bool addSkTypeface(NativeFamilyBuilder* builder, sk_sp<SkData>&& data, in
127127
args.setVariationDesignPosition({skVariation.data(), static_cast<int>(skVariation.size())});
128128

129129
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
130+
if (fontData == NULL || fontData == nullptr) {
131+
ALOGE("addFont failed to create font, invalid font data");
132+
builder->axes.clear();
133+
return false;
134+
}
130135
sk_sp<SkTypeface> face(fm->makeFromStream(std::move(fontData), args));
131-
if (face == NULL) {
136+
if (face == NULL || face == nullptr) {
132137
ALOGE("addFont failed to create font, invalid request");
133138
builder->axes.clear();
134139
return false;

libs/hwui/jni/fonts/Font.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ static jlong Font_Builder_build(JNIEnv* env, jobject clazz, jlong builderPtr, jo
105105
std::move(data), std::string_view(fontPath.c_str(), fontPath.size()),
106106
fontPtr, fontSize, ttcIndex, builder->axes);
107107
if (minikinFont == nullptr) {
108-
jniThrowException(env, "java/lang/IllegalArgumentException",
109-
"Failed to create internal object. maybe invalid font data.");
108+
ALOGE("Failed to create internal object. maybe invalid font data. fontPath %s", fontPath.c_str());
110109
return 0;
111110
}
112111
uint32_t localeListId = minikin::registerLocaleList(langTagStr.c_str());
@@ -459,6 +458,9 @@ std::shared_ptr<minikin::MinikinFont> createMinikinFontSkia(
459458
args.setVariationDesignPosition({skVariation.data(), static_cast<int>(skVariation.size())});
460459

461460
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
461+
if (fontData == nullptr) {
462+
return nullptr;
463+
}
462464
sk_sp<SkTypeface> face(fm->makeFromStream(std::move(fontData), args));
463465
if (face == nullptr) {
464466
return nullptr;

0 commit comments

Comments
 (0)