ConcreteShadowNode::getConcreteSharedProps() returns a reference to a temporary
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc packages/react-native/ReactCommon/react/renderer/core/ConcreteShadowNode.h, đặc biệt là các dòng 144–148, và kiểm tra kiểu trả về cùng phần triển khai của getConcreteSharedProps(). Biên dịch reproducer được cung cấp với -Wreturn-stack-address để xác nhận cảnh báo, sau đó cập nhật phương thức để giá trị trả về vẫn hợp lệ, đồng thời giữ nguyên tên và tính const được yêu cầu. Hoàn thành khi reproducer biên dịch mà không có cảnh báo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
ConcreteShadowNode::getConcreteSharedProps() (ConcreteShadowNode.h) is declared to return const std::shared_ptr<const ConcreteProps> & and returns std::static_pointer_cast<const ConcreteProps>(props_), a temporary destroyed as the function returns, so every caller gets a reference to a destroyed shared_ptr. Nitro's generated view components called it until margelo/nitro#1502 moved them to getProps().
Steps to reproduce
- Clone the reproducer below and run
bash repro.shon Ubuntu 24.04 withclang git libboost-dev libgoogle-glog-dev libdouble-conversion-devfrom apt, or thedocker runline in its README. It clones react-native'smain, and folly, fast_float and fmt at the versionspackages/react-native/gradle/libs.versions.tomlpins. - It compiles
repro.cpp, which declares a component's shadow node,ConcreteShadowNode<ProbeComponentName, ShadowNode, Props>, and a function that returnsshadowNode.getConcreteSharedProps().
Expected: repro.cpp compiles without a warning: getConcreteSharedProps() returns the shared_ptr by value, or a reference to one that outlives the call, and keeps its name and its const.
Actual: clang reports returning reference to local temporary object at the function's return, ConcreteShadowNode.h:147.
React Native Version
0.88.1
Affected Platforms
Other (please specify)
Output of npx @react-native-community/cli info
Not an app. The reproducer compiles ReactCommon from react-native's main at b9a83f3 (0.88.0 and 0.88.1 have the
same getConcreteSharedProps), on Ubuntu 24.04 with clang 18.1.3, folly 2024.11.18.00, fast_float 8.0.0 and
fmt 12.1.0. ReactCommon is shared by Android and iOS.
Stacktrace or Logs
react/react-native b9a83f3, Ubuntu clang version 18.1.3 (1ubuntu1), Linux x86_64
folly 2024.11.18.00, fast_float 8.0.0 and fmt 12.1.0, as libs.versions.toml pins them
compiling repro.cpp, whose sharedPropsOf() returns shadowNode.getConcreteSharedProps(), with -Wreturn-stack-address
ReactCommon/react/renderer/core/ConcreteShadowNode.h:147:12: warning: returning reference to local temporary object [-Wreturn-stack-address]
147 | return std::static_pointer_cast<const ConcreteProps>(props_);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
summary: react/react-native b9a83f3: clang reports that ConcreteShadowNode::getConcreteSharedProps() returns a reference to a temporary
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/concrete-shadow-node-dangling-shared-props
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.5k
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 188
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react/react-native
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
react/react-native#59945 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
react/react-native#59942 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
react/react-native#59939 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
react/react-native#59929 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryCó thể đã có người làm @alleneubank đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
react/react-native#59919 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của react/react-native
Issue tương tự
-
type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
tensorflow/tflite-micro#3995 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
not for AI lovers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
OSGeo/gdal#15515 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
VT: Backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
contour-terminal/contour#2314 ·
Maintainer thường phản hồi trong vòng 1 ngày