【发布时间】:2022-07-07 04:29:05
【问题描述】:
我正在努力使用 protobuf 设置器。每当我尝试使用它时程序就会终止。
BluetoothDevice bluetoothDevice;
bluetoothDevice.set_name(std::string(name));
另外,当我使用带有预分配对象的已分配 setter 版本时,它可以工作。 我得到了堆栈跟踪。
Callstack Information (PID:10157)
Call Stack Count: 22
0: google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*) + 0x83 (0x98adc6c8) [/usr/lib/libprotobuf-lite.so.25.0.0] + 0x326c8
1: BluetoothDevice::set_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) + 0x58 (0x98d36a2c) [/opt/usr/globalapps/com.samsung.jrazek.flutter_blue_tizen_example/lib/libflutter_plugins.so] + 0x202a2c
2: btu::BluetoothManager::notifyDiscoveryResultLE(bt_adapter_le_device_scan_result_info_s const&) + 0x2b8 (0x98d36230) [/opt/usr/globalapps/com.samsung.jrazek.flutter_blue_tizen_example/lib/libflutter_plugins.so] + 0x202230
3: btu::BluetoothManager::adapterDeviceDiscoveryStateChangedCallbackLE(int, bt_adapter_le_device_scan_result_info_s*, void*) + 0xa8 (0x98d35f40) [/opt/usr/globalapps/com.samsung.jrazek.flutter_blue_tizen_example/lib/libflutter_plugins.so] + 0x201f40
4: (0x989f6ee9) [/usr/lib/libcapi-network-bluetooth.so.0.6.0] + 0x14ee9
5: g_variant_lookup_value + 0xbec7 (0x98969ec7) [/usr/lib/libbluetooth-api.so.1.0.0] + 0xbec7
6: (0x9898fb27) [/usr/lib/libbluetooth-api.so.1.0.0] + 0x31b27
7: (0xb664ee17) [/usr/lib/libgio-2.0.so.0.6200.3] + 0xb6e17
8: g_main_context_dispatch + 0xcc (0xb68fdd85) [/usr/lib/libglib-2.0.so.0.6200.3] + 0x3bd85
9: (0xb6ee5021) [/usr/lib/libecore.so.1.25.1] + 0x17021
10: (0xb6ee6c45) [/usr/lib/libecore.so.1.25.1] + 0x18c45
11: (0xb6ee71db) [/usr/lib/libecore.so.1.25.1] + 0x191db
12: (0xb6ee775f) [/usr/lib/libecore.so.1.25.1] + 0x1975f
13: (0xb6eeaf5f) [/usr/lib/libecore.so.1.25.1] + 0x1cf5f
14: efl_loop_begin + 0x50 (0xb6eea40d) [/usr/lib/libecore.so.1.25.1] + 0x1c40d
15: ecore_main_loop_begin + 0x4e (0xb6ee64c7) [/usr/lib/libecore.so.1.25.1] + 0x184c7
16: appcore_base_init + 0x186 (0xb5da1817) [/usr/lib/libappcore-common.so.1.15.1] + 0x4817
17: appcore_ui_base_init + 0x164 (0xa43894e1) [/usr/lib/libappcore-ui.so.1.15.1] + 0x34e1
18: appcore_efl_base_init + 0x3c (0xa43c61dd) [/usr/lib/libappcore-efl.so.1.15.1] + 0x21dd
19: (0xa43d9383) [/usr/lib/libcapi-appfw-application.so.0.5.26] + 0x1383
20: ui_app_main + 0x80 (0xa43d9599) [/usr/lib/libcapi-appfw-application.so.0.5.26] + 0x1599
21: (0xa471de91) [/usr/share/dotnet.tizen/framework/Tizen.Applications.UI.ni.dll] + 0x1e91
End of Call Stack
STACK_SHA256: 11fd110e322b45c53225b556f3dbafbabbf86fdcf31d563c133f84393c081a61
protobuf 类:
message BluetoothDevice {
enum Type {
UNKNOWN = 0;
CLASSIC = 1;
LE = 2;
DUAL = 3;
};
string remote_id = 1;
string name = 2;
Type type = 3;
}
我在这里可能做错了什么?
【问题讨论】:
-
我不排除这是 protobuf 中的错误。除非您以某种从您的问题中不清楚的特定方式初始化 protobuf 本身,否则您提到的两行应该按原样工作。也许在 GitHub 上向他们开一张票。
-
@Qix-MONICAWASMISTREATED 同意,但是,OP 并不是第一个使用 protobuf 的人,而且代码看起来非常简单——它可能是什么错误?所以那里有一些东西。我的第一行调查将是损坏的安装。 protobuf lib 是如何安装的?它是共享的还是静态的?我们确定运行时 C/C++ 是相同的吗?我们确定 ABI 兼容吗?
-
库是使用此设置构建的
./configure --build=x86_64-pc-linux-gnu --prefix=/home/user/libs --host=arm-linux-gnueabi CC="arm-linux-gnueabi-gcc" CXX="arm-linux-gnueabi-g++"这是一个共享库。另外值得一提的是,我使用的是精简版的 protobuf。在生成 protobuf 文件期间,我使用了option optimize_for = LITE_RUNTIME;选项
标签: c++ protocol-buffers