Android application crashes because of protobuf

与世无争的帅哥 提交于 2019-12-11 05:45:22

问题


I have an Android application implemented with help of cocos2d-x engine. I linked protobuf library to the project and trying to SerializeToStrint() one proto-object:

ProtoMessage message;
message.set_app_id(1111);
message.set_hardware_id("test string");

std::string str;

message.SerializeToString(&str);

That's builds fine, but when I trying to start application logcat send me next log:

09-14 10:26:51.748 13009 13009 I DEBUG   : Build fingerprint: 
verizon/droid2we_vzw/cdma_droid2we:2.3.4/4.5.1_57_D2GA-59/120117:user/release-keys
09-14 10:26:51.748 13009 13009 I DEBUG   : pid: 12996, tid: 13008  >>> com.karmicapps <<<
09-14 10:26:51.748 13009 13009 I DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
09-14 10:26:51.748 13009 13009 I DEBUG   :  r0 00000027  r1 deadbaad  r2 a0000000  r3 00000000
09-14 10:26:51.748 13009 13009 I DEBUG   :  r4 00000001  r5 00000000  r6 81b15340  r7 0000a000
09-14 10:26:51.748 13009 13009 I DEBUG   :  r8 818d4ed1  r9 44df07c8  10 00100000  fp 00000001
09-14 10:26:51.748 13009 13009 I DEBUG   :  ip afd466c8  sp 45ac1df8  lr afd19239  pc afd15d08  cpsr 60000070
09-14 10:26:51.748 13009 13009 I DEBUG   :  d0  643a64696f72646e  d1  6472656767756265
09-14 10:26:51.748 13009 13009 I DEBUG   :  d2  0049002e00690045  d3  0066007200750047
09-14 10:26:51.748 13009 13009 I DEBUG   :  d4  0000000000000000  d5  0000000100000000
09-14 10:26:51.748 13009 13009 I DEBUG   :  d6  000000000000f760  d7  0000000000000000
09-14 10:26:51.748 13009 13009 I DEBUG   :  d8  0000000000000000  d9  0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d10 0000000000000000  d11 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d12 0000000000000000  d13 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d14 0000000000000000  d15 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d16 3fdd938000000280  d17 3fdfffffffffe114
09-14 10:26:51.756 13009 13009 I DEBUG   :  d18 3fe0000000000000  d19 3fe0000000000f76
09-14 10:26:51.756 13009 13009 I DEBUG   :  d20 0000000000000000  d21 3f872e5c54a96637
09-14 10:26:51.756 13009 13009 I DEBUG   :  d22 3e21e7c5992989f4  d23 bda8fae9be8838d4
09-14 10:26:51.756 13009 13009 I DEBUG   :  d24 3fc74721cad6b0ed  d25 3fc39a09d078c69f
09-14 10:26:51.756 13009 13009 I DEBUG   :  d26 0000000000000000  d27 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d28 0000000000000000  d29 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  d30 0000000000000000  d31 0000000000000000
09-14 10:26:51.756 13009 13009 I DEBUG   :  scr 20000012
09-14 10:26:51.756 13009 13009 I DEBUG   : 
09-14 10:26:51.803 13009 13009 I DEBUG   :          #00  pc 00015d08  /system/lib/libc.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #01  pc 00013674  /system/lib/libc.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #02  pc 0001453a  /system/lib/libc.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #03  pc 000a45ec  /data/data/com.example/lib/libprotobuf.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #04  pc 000a46d0  /data/data/com.example/lib/libprotobuf.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #05  pc 000445ac  /data/data/com.example/lib/libprotobuf.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #06  pc 000445f6  /data/data/com.example/lib/libprotobuf.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #07  pc 00044616  /data/data/com.example/lib/libprotobuf.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #08  pc 000d51f8  /data/data/com.example/lib/libpromowall.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #09  pc 000d4ee4  /data/data/com.example/lib/libpromowall.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #10  pc 0001194c  /system/lib/libc.so
09-14 10:26:51.803 13009 13009 I DEBUG   :          #11  pc 00011510  /system/lib/libc.so
09-14 10:26:51.803 13009 13009 I DEBUG   : 
09-14 10:26:51.803 13009 13009 I DEBUG   : code around pc:
09-14 10:26:51.803 13009 13009 I DEBUG   : afd15ce8 2c006824 e028d1fb b13368db c064f8df 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd15cf8 44fc2401 4000f8cc 49124798 25002027 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd15d08 f7f57008 2106ec72 edd6f7f6 460aa901 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd15d18 f04f2006 95015380 95029303 e934f7f6 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd15d28 462aa905 f7f62002 f7f5e940 2106ec5e 
09-14 10:26:51.803 13009 13009 I DEBUG   : 
09-14 10:26:51.803 13009 13009 I DEBUG   : code around lr:
09-14 10:26:51.803 13009 13009 I DEBUG   : afd19218 4a0e4b0d e92d447b 589c41f0 26004680 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd19228 686768a5 f9b5e006 b113300c 47c04628 
09-14 10:26:51.803 13009 13009 I DEBUG   : afd19238 35544306 37fff117 6824d5f5 d1ef2c00 
09-14 10:26:51.811 13009 13009 I DEBUG   : afd19248 e8bd4630 bf0081f0 00028344 ffffff88 
09-14 10:26:51.811 13009 13009 I DEBUG   : afd19258 b086b570 f602fb01 9004460c a804a901 
09-14 10:26:51.811 13009 13009 I DEBUG   : 
09-14 10:26:51.811 13009 13009 I DEBUG   : stack:
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1db8  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dbc  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dc0  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dc4  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dc8  afd4276c  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dcc  afd42718  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dd0  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dd4  afd19239  /system/lib/libc.so
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dd8  00000001  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1ddc  45ac1e0c  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1de0  81b15340  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1de4  0000a000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1de8  818d4ed1  /data/data/com.karmicapps/lib/libpromowall.so
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dec  afd1855b  /system/lib/libc.so
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1df0  df002777  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1df4  e3a070ad  
09-14 10:26:51.811 13009 13009 I DEBUG   : #00 45ac1df8  0000001b  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1dfc  0000000e  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e00  45ac1eac  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e04  002ddb2c  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e08  81b15340  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e0c  fffffbdf  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e10  818d4ed1  /data/data/com.karmicapps/lib/libpromowall.so
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e14  afd464b0  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e18  002ddb2c  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e1c  afd13679  /system/lib/libc.so
09-14 10:26:51.811 13009 13009 I DEBUG   : #01 45ac1e20  45ac1eac  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e24  002ddb2c  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e28  0000000e  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e2c  00000000  
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e30  818d4ed1  /data/data/com.karmicapps/lib/libpromowall.so
09-14 10:26:51.811 13009 13009 I DEBUG   :     45ac1e34  afd1453d  /system/lib/libc.so

Please can anybody explain me causes of this?

UPDATE But if I initialize string in such way:

ProtoMessage message;
message.set_app_id(1111);
message.set_hardware_id("test string");

std::string str;
str = "test";

message.SerializeToString(&str);

everything is fine and proto serializes normally

UPDATED I added a add2line result below

new stack trace:

#00  pc 00016f20  /system/lib/libc.so
#01  pc 00014878  /system/lib/libc.so
#02  pc 00015756  /system/lib/libc.so
#03  pc 0018dd64  /data/data/com.example/lib/libprotobuf.so   ---- std::string::reserve(unsigned int) 
#04  pc 0018de60  /data/data/com.example/lib/libprotobuf.so   ---- std::string::append(unsigned int, char)
#05  pc 000eff6c  /data/data/com.example/lib/libprotobuf.so   ---- google::protobuf::STLStringResizeUninitialized(std::string*, unsigned int)
#06  pc 000f1c96  /data/data/com.example/lib/libprotobuf.so   ---- google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)
#07  pc 001013b4  /data/data/com.example/lib/libpromowall.so  ---- google::protobuf::DescriptorBuilder::NewPlaceholderFile(std::string const&)

UPDATE and the most annoying problem I can't parse proto-object without string fields initialization.

//str - serializing protobuf object
RegistrationRequest request;
request.ParseFromString(str);

Error! When I compile that in test application on my desctop machine everything is fine. But If I compile via cocos2d-x script (ndk.r7) application crashes on mobile device


回答1:


Make sure libprotobuf.so and libpromowall.so are built with the same STL implementation: either stlport_shared or gnustl_shared.



来源:https://stackoverflow.com/questions/12420850/android-application-crashes-because-of-protobuf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!