- 
    
Bug
 - 
    Resolution: Cannot Reproduce
 - 
    
P1: Critical
 - 
    None
 - 
    5.15.2
 - 
    None
 
- 
        
 - 
        6d306a0e3755258beb11d7f488c2bb1bf66bec19
 
Device Environment:
Qt 5.15.2 (arm64-little_endian-lp64 shared (dynamic) release build; by Clang 13.1.6 (clang-1316.0.21.2.5) (Apple)) on "cocoa" OS: macOS 14.4 [darwin version 23.4.0] Architecture: arm64; features: Neon File selectors (increasing order of precedence): zh_CN unix darwin mac osx macos
Reproduction Status:
Windows: not reproduced, Mac: reproduced
Trigger Scenario:
If a widget uses a stylesheet to set an unavailable font, and the widget's text contains the following two types of characters:
1. [U+4E00 to U+9FFF], which are CJK Unified Ideographs
2. [U+2068], the First Strong Isolate
Then, while rendering the widget, Qt crashes.
lldb Debugging Information:
2024-11-21 15:51:11.730173+0800 SimpleQtApp[32319:38291159] [qt.qpa.fonts] Populating font family aliases took 73 ms. Replace uses of missing font family "An Unexist Font" with one that exists to avoid this cost.
Process 32319 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16fe00000)
    frame #0: 0x00000001005575ec QtGui`QTextEngine::shapeText(int) const + 2308
QtGui`QTextEngine::shapeText:
->  0x1005575ec <+2308>: ldrb   w12, [x10]
    0x1005575f0 <+2312>: and    w12, w12, #0xffffffc3
    0x1005575f4 <+2316>: strb   w12, [x10], #0x1
    0x1005575f8 <+2320>: subs   x11, x11, #0x1
Target 0: (SimpleQtApp) stopped.
Minimal Reproduction Code:
// main.cpp
#include <QApplication>
#include <QLabel>
#include <QString>
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  QLabel label;
  label.resize(200, 100);
  std::string style_sheet = R"(
    QLabel {
      font-family: "An unexist font";
    }
  )";
  label.setStyleSheet(QString::fromStdString(style_sheet)); // Commenting out this line will prevent the crash
  label.setText("字 ");
  label.show();
  return app.exec();
}
# CMakeLists.txt cmake_minimum_required(VERSION 3.14) project(SimpleQtApp LANGUAGES CXX) set(CMAKE_PREFIX_PATH "/Users/huangzhelin/Documents/Tests/Qt5.15.2") find_package(Qt5 REQUIRED COMPONENTS Widgets) add_executable(SimpleQtApp main.cpp) target_link_libraries(SimpleQtApp Qt5::Widgets)