【发布时间】:2016-05-11 13:14:56
【问题描述】:
protobuf 版本是 3.0.0。在某些设备(比如 Android 6)中,这个问题总是会发生;在某些设备(例如 Android 5.x)中,当应用进入后台模式时会出现此问题。
我正在调用以下方法:
bool ParseFromString(const string& data);
这可能在内部调用bool ParseFromArray(const void* data, int size)。堆栈跟踪:
Build fingerprint: 'lge/b2lds_global_com/b2lds:5.0.2/LRX22G/152532131cf4c:user/release-keys'
Revision: '1.0'
ABI: 'arm'
pid: 9946, tid: 9970, name: ahlaad.saarathy >>> com.org.aahlaad.saarathy <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadbaad
Abort message: 'invalid address or address of corrupt block 0xa19fca5c passed to dlfree'
r0 ffffffff r1 deadbaad r2 73797300 r3 2e6d6f63
r4 b6f2bfd8 r5 a19fca5c r6 a19469e4 r7 b6f310fc
r8 a19fca64 r9 a1c417b0 sl 00000000 fp a1946a64
ip 00000000 sp a19469a8 lr b6efe031 pc b6efe034 cpsr 800f0030
backtrace:
#00 pc 00027034 /system/lib/libc.so (__bionic_heap_usage_error+35)
#01 pc 00029853 /system/lib/libc.so (dlfree+1354)
#02 pc 0000f0e7 /system/lib/libc.so (free+10)
#03 pc 001bc24d /data/app/com.org.aahlaad.saarathy-1/lib/arm/libprotobuf.so
#04 pc 001bc4d7 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libprotobuf.so
===> #05 pc 000dde37 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libprotobuf.so (google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)+50)
#06 pc 00060944 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libsaarathyclient.so (Saarathy::Messaging::Convey::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)+480)
#07 pc 000d7bdd /data/app/com.org.aahlaad.saarathy-1/lib/arm/libprotobuf.so (google::protobuf::MessageLite::ParseFromString(std::string const&)+48)
#08 pc 00022d84 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libsaarathyclient.so (Connection::CloudSSL::DecodeProtoBuffer(unsigned int, std::string const&)+580)
#09 pc 00024f0c /data/app/com.org.aahlaad.saarathy-1/lib/arm/libsaarathyclient.so (Connection::CloudSSL::Receive()+308)
#10 pc 0002af68 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libsaarathyclient.so (Util::Synchronized_<Connection::CloudSSL>::Start()::{lambda()#1}::operator()() const+72)
#11 pc 00091207 /data/app/com.org.aahlaad.saarathy-1/lib/arm/libgnustl_shared.so (execute_native_thread_routine+14)
#12 pc 00012f57 /system/lib/libc.so (__pthread_start(void*)+30)
#13 pc 00011017 /system/lib/libc.so (__start_thread+6)
显然如箭头所示,它在google::protobuf::internal::WireFormatLite::ReadBytes(...) 处崩溃。这个问题已经在this thread 中讨论过,用户通过将 VS2005 升级到 VS2008 来修复它。但是我们在 Android 中运行它。
我也参考了以下帖子无济于事:
- Android application crashes because of protobuf
- Crash when parsing protobuf message containing a string using C++ and Android NDK
- zeromq with protobuf segmentation fault while parsing in c++
- Generated Protobuf code crashes application
感谢任何详细的帮助,因为我是使用 Android 构建 protobuf 库的新手。
【问题讨论】:
标签: android c++ crash protocol-buffers