struct DV_COMMON_EXPORT product_config {
int detect_delay_ms = 0;
int reject_delay_ms = 0;
int detect_count_oneshot = 1;
int detect_count = 0;
int detect_count_interval = 100;
std::string ref_image_path = "1";
int cam_x =2;
int cam_y =3;
// yuv420p",rgb888
std::string rpicam_pixel_type = "yuv420p";
int tmp =44;
};
调试时发现从第一个字符串往后,字段都没有正常初始化
(gdb) info line
Line 1021 of "/repos/dv_app_solution/prism_all/prism/include/prism/prismJson.hpp"
starts at address 0x7fffeb60f470 <prism::json::fromJsonString<dv_common_config>(std::string const&&)+28>
and ends at 0x7fffeb60f478 <prism::json::fromJsonString<dv_common_config>(std::string const&&)+36>.
(gdb) list
1016
1017 template <class T>
1018 static inline std::unique_ptr<T> fromJsonString(const std::string&& str)
1019 {
1020 std::unique_ptr<T> model = std::make_unique<T>();
1021 privates::jsonType<T>::type::from_jsonStr(std::move(*model), std::move(str), 0, static_cast<int>(str.length() - 1));
1022
1023 return model;
1024 }
1025 template <class T>
(gdb) print *model
$9 = {detect_delay_ms = 0, reject_delay_ms = 0, detect_count_oneshot = 1, detect_count = 0, detect_count_interval = 100, ref_image_path = "", cam_x = 0,
cam_y = 0, rpicam_pixel_type = <error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.>, tmp = 796092265}
(gdb)
程序会在后面的逻辑中,崩溃在使用 rpicam_pixel_type 这个字段的时候,用 asan 看了是由于这个错误的字符串被认为超过 10 个 T 导致崩溃 随便把它赋值给其他变量就会崩溃
没有思路,有什么方式进一进定位吗
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.