GreeterClient::SayHello() crashes when running Release 11 C++ example in VS-2013

288 views
Skip to first unread message

Rich Armington

unread,
Sep 21, 2015, 10:55:42 AM9/21/15
to grpc.io

We are evaluating gRPC  as a potential replacement for our current communication protocol. Our customer expects systems running on Windows so I have recursively cloned the gRPC repository at the release-0_11 tag and built protoc, grpc_cpp_plugin, grpc++_unsecure.lib (secure connections aren’t required for our application) etc.  per the README’s (they do need to be updated) in VS2013. I also created projects and built the ‘examples/cpp/helloworld’ async server and client successfully. The server runs but when the client attempts to “SayHello”, that is, the method GreeterClient::SayHello() is called, it fails  with the exception:

 

Unhandled exception at 0x013C7CCF in GreeterClient.exe: 0xC0000005: Access violation reading location 0x00000000. 


when calling:

std::unique_ptr<ClientAsyncResponseReader<HelloReply> > rpc(

        stub_->AsyncSayHello(&context, request, &cq));


The errant line appears to be:

for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i)


in Call::FillMetadataArray()


when calling begin() from metadata.cbegin():


Here is the entire method from Call.cc:

grpc_metadata* FillMetadataArray(

    const std::multimap<grpc::string, grpc::string>& metadata) {

  if (metadata.empty()) {

    return nullptr;

  }

  grpc_metadata* metadata_array =

      (grpc_metadata*)gpr_malloc(metadata.size() * sizeof(grpc_metadata));

  size_t i = 0;

  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {

    metadata_array[i].key = iter->first.c_str();

    metadata_array[i].value = iter->second.c_str();

    metadata_array[i].value_length = iter->second.size();

  }

  return metadata_array;

}

 

I haven’t modified the code in any way, however I did create Visual Studio solutions for each of the GreeterClient and GretterServer.

Can you offer any ideas of what’s going on here?


Thanks for you help,

Rich

Michael Larson

unread,
Sep 21, 2015, 6:27:26 PM9/21/15
to Rich Armington, grpc.io
see


and


best practice currently is to remove _USE_32BIT_TIME_T from the grpc libraries if you use std::chrono or to add it to your project if you don't

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f209189d-8061-4b59-b08b-9697258b0d7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rich Armington

unread,
Sep 22, 2015, 10:15:48 AM9/22/15
to grpc.io, rsarm...@gmail.com
Adding _USE_32BIT_TIME_T as a preprocessor definition in both projects solved the problem. I originally built the project files using the example's makefile as a reference and it's not included in the compiler flags, so I wasn't aware it was needed.

Thanks,
Rich
Reply all
Reply to author
Forward
0 new messages