x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Android NDK]App crashed when invoke ParseFromArray() of protobuf

this's my proto file:

 message role_data {
     required string  id                    = 1;    
     required int32  atk                    = 2;    
     required int32  hp_max                = 3;    
     required int32  mp_max                = 4;    
 }


this's my testing code:

 HProtocol::role_data role;
 
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 111111111"));
 
 role.set_id("wag");
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 2222222222"));
 
 role.set_atk(999);
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 333333333"));
 
 role.set_hp_max(888);
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 44444444"));
 
 role.set_mp_max(777);
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 5555"));
 
 int BSize = role.ByteSize();
 char* buf = new char[BSize];
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 6666"));
 
 role.SerializeToArray(buf, BSize);
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 777"));
 
 HProtocol::role_data role2;
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 888"));
 
 bool rs = role2.ParseFromArray(buf, BSize);
 UE_LOG(LogTemp, Display, TEXT("[PVPModule::OnCustomMatchReturn] 999 SUCCESS:%d"), rs);


this's the debug info in console of android sdk monitor: alt text

this's crash dump that cause by ParseFromArray() of protobuf API

 ********** Crash dump: **********
 Build fingerprint: 'Xiaomi/helium/helium:6.0.1/MMB29M/6.9.29:user/release-keys'
 pid: 16141, tid: 16172, name: Thread-5372  >>> com.test.HuaiKX <<<
 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
 Stack frame 10-17 03:07:04.637 31796 31796 F DEBUG   :     #00 pc 00000000  <unknown>: Unable to open symbol file D:\workspace\unreal_project\huaikongxin2\program\client\HuaiKXCli\Intermediate\Android\APK\obj\local\armeabi-v7a/<unknown>. Error (22): Invalid argument
 Stack frame 10-17 03:07:04.637 31796 31796 F DEBUG   :     #01 pc 01984117  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN6google8protobuf11MessageLite14ParseFromArrayEPKvi+10): Routine InlineParseFromArray at D:\workspace\unreal_project\huaikongxin2\program\common\custom_msg\android_ndk_build/jni/google/protobuf/message_lite.cc:142
 Stack frame 10-17 03:07:04.637 31796 31796 F DEBUG   :     #02 pc 018c824c  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN9PVPModule19OnCustomMatchReturnEPKci+1080): Routine PVPModule::OnCustomMatchReturn(char const*, int) at D:\workspace\unreal_project\huaikongxin2\program\client\HuaiKXCli\Source\HuaiKX\Logic\Private\PVPModule/PVPModule.cpp:101
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #03 pc 018dd32c  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN9HServices15HCallbackMaster19InvokeCustomCallFunEiPKci+440): Routine HServices::HCallbackMaster::InvokeCustomCallFun(int, char const*, int) at D:\workspace\unreal_project\huaikongxin2\program\client\HuaiKXCli\Source\HuaiKX\Services\Master/HCallbackMaster.cpp:592
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #04 pc 018e3074  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN9HServices13HObjectMaster15OnCustomMessageEPKci+92): Routine HServices::HObjectMaster::OnCustomMessage(char const*, int) at D:\workspace\unreal_project\huaikongxin2\program\client\HuaiKXCli\Source\HuaiKX\Services\Master/HObjectMaster.cpp:93
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #05 pc 018c2bd0  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN10AHGameMode4TickEf+152): Routine AHGameMode::Tick(float) at D:\workspace\unreal_project\huaikongxin2\program\client\HuaiKXCli\Source\HuaiKX\Graphics\World/HGameMode.cpp:135
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #06 pc 01fdcdd8  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN18FActorTickFunction11ExecuteTickEf10ELevelTickN13ENamedThreads4TypeERK12TRefCountPtrI11FGraphEventE+1044): Routine FActorTickFunction::ExecuteTick(float, ELevelTick, ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&) at ??:?
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #07 pc 02ddec44  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN17FTickFunctionTask6DoTaskEN13ENamedThreads4TypeERK12TRefCountPtrI11FGraphEventE+312): Routine FTickFunctionTask::DoTask(ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&) at ??:?
 Stack frame 10-17 03:07:04.638 31796 31796 F DEBUG   :     #08 pc 02dde7e4  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN10TGraphTaskI17FTickFunctionTaskE11ExecuteTaskER6TArrayIP14FBaseGraphTask17FDefaultAllocatorEN13ENamedThreads4TypeE+540): Routine TGraphTask<FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask*, FDefaultAllocator>&, ENamedThreads::Type) at ??:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #09 pc 01a0bd08  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN16FNamedTaskThread23ProcessTasksNamedThreadEib+8212): Routine $a.2140 at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #10 pc 01a09530  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN16FNamedTaskThread21ProcessTasksUntilQuitEi+184): Routine FNamedTaskThread::ProcessTasksUntilQuit(int) at ??:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #11 pc 02dd9ab8  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN18FTickTaskSequencer16ReleaseTickGroupE13ETickingGroupb+2376): Routine FTickTaskSequencer::ReleaseTickGroup(ETickingGroup, bool) at ??:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #12 pc 02dd3934  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN16FTickTaskManager12RunTickGroupE13ETickingGroupb+228): Routine FTickTaskManager::RunTickGroup(ETickingGroup, bool) at ??:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #13 pc 026d6b20  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN6UWorld4TickE10ELevelTickf+6360): Routine $a.465 at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #14 pc 0250cc0c  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN11UGameEngine4TickEfb+6468): Routine $a.822 at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.639 31796 31796 F DEBUG   :     #15 pc 0199a084  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_ZN11FEngineLoop4TickEv+14500): Routine $a.349 at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.640 31796 31796 F DEBUG   :     #16 pc 019932b0  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (_Z11AndroidMainP11android_app+4644): Routine $a.275 at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.640 31796 31796 F DEBUG   :     #17 pc 0199e6c4  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so (android_main+220): Routine android_main at ??:?
 Stack frame 10-17 03:07:04.640 31796 31796 F DEBUG   :     #18 pc 019be838  /data/app/com.test.HuaiKX-1/lib/arm/libUE4.so: Routine android_app_entry at zero_copy_stream.cc:?
 Stack frame 10-17 03:07:04.640 31796 31796 F DEBUG   :     #19 pc 00041843  /system/lib/libc.so (_ZL15__pthread_startPv+30)
 Stack frame 10-17 03:07:04.640 31796 31796 F DEBUG   :     #20 pc 000192a5  /system/lib/libc.so (__start_thread+6)

I don't how to solve this issue, does anybody have the same problem before?

Product Version: UE 4.13
Tags:
20161017_1.png (20.0 kB)
more ▼

asked Oct 16 '16 at 07:29 PM in C++ Programming

avatar image

笑傲江湖-DA
216 13 24 31

avatar image Doug E ♦♦ STAFF Oct 17 '16 at 06:48 PM

Hello,

Can you explain where you're using / calling this code? If you're able to reproduce this crash, please provide the steps to help investigate the crash locally. Also include the full callstack and log files from the crash for additional information.

avatar image 笑傲江湖-DA Oct 18 '16 at 10:32 AM

Apologies for the delay. Now I have uploaded the project which can reproduce this issue, steps have been put in it. https://app.box.com/s/gs56zgdolwe0wfe5rhr6rc1si160jvvt

avatar image Doug E ♦♦ STAFF Oct 18 '16 at 02:31 PM

Can you explain where the crash occurs? I followed the instructions from your text document and then compiled the project for Android. The package process completed successfully and I was able to launch the project on the testing device. If you're still getting a crash with the project you sent, can you provide the Android version the phone is on as well as the the phone model so that I can make sure I am testing on similar hardware.

avatar image 笑傲江湖-DA Oct 18 '16 at 04:23 PM

Android version is 6.0.1. my phone is Mi Max (xiaomi), and build mode of UE4 is DebugGame

avatar image YangTianTian Feb 16 '17 at 04:21 AM

i meet the same crash in android runtime. link text

don't know how to fix this.

log(2).txt (4.1 kB)
avatar image pfepark Feb 21 '18 at 01:19 PM

I met the same thing. crash in android runtime.

How can i fix it? please help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I took me ages to figure it out, I code a function to implement MessageLite::ParseFromArray(), and it works right. I don't know why, It seems a bug of UE4 building, as I know, MessageLite::ParseFromArray() works well in cocos2dx project.

 #ifndef    __ProtobufHelper_H__
 #define    __ProtobufHelper_H__
 
 #include <google/protobuf/message_lite.h>
 #include <google/protobuf/io/coded_stream.h>
 
 class ProtobufHelper
 {
 public:
 
     static bool Parse(::google::protobuf::MessageLite& Message, const char* Data, int Size)
     {
         ::google::protobuf::io::CodedInputStream input(reinterpret_cast<const uint8*>(Data), Size);
 
         return Message.MergePartialFromCodedStream(&input) && input.ConsumedEntireMessage();
     }
 };
 
 #endif

invoke:

 HProtocol::role_data role2; 
 bool rs = ProtobufHelper::Parse(role2, buf, BSize);

more ▼

answered Oct 17 '16 at 02:48 PM

avatar image

笑傲江湖-DA
216 13 24 31

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question