Thanks a bunch Vijay,

I had foolishly made an assumption because there wasn't error checking in 
the example that a valid pointer was always returned at this point. You 
were right about the port also and so I've learned something about the 
history of Linux ports < 1024, which I probably should have known by now 
already!...

On Monday, September 10, 2018 at 11:42:51 PM UTC+1, Vijay Pai wrote:
>
>  In particular, a reason that this is likely to fail out is that your 
> listening port is #1000 , which will only work if you are root.
>
> On Monday, September 10, 2018 at 3:35:33 PM UTC-7, Yang Gao wrote:
>>
>> The first thing I would check is whether server_ == nullptr after 
>> BuildAndStart.
>>
>> On Mon, Sep 10, 2018 at 3:22 PM Alistair Lowe <[email protected]> 
>> wrote:
>>
>>> Hi guys,
>>>
>>> I'm trying to implement my own gRPC 1.14.2 C++ async server loosely 
>>> following the hello world examples, however I receive a segfault when 
>>> attempting to make an asynchronous request as per the below stack trace:
>>>
>>> grpc::ServerInterface::RegisteredAsyncRequest::IssueRequest(void*, 
>>> grpc_byte_buffer**, grpc::ServerCompletionQueue*) (Unknown Source:0)
>>> grpc::ServerInterface::PayloadAsyncRequest<OpenIoTServer::EnrollRequest>::PayloadAsyncRequest(grpc::ServerInterface::PayloadAsyncRequest<OpenIoTServer::EnrollRequest>
>>>  
>>> * const this, void * registered_method, grpc::ServerInterface * server, 
>>> grpc::ServerContext * context, 
>>> grpc::internal::ServerAsyncStreamingInterface * stream, 
>>> grpc::CompletionQueue * call_cq, grpc::ServerCompletionQueue * 
>>> notification_cq, void * tag, OpenIoTServer::EnrollRequest * request) 
>>> (/usr/local/include/grpcpp/impl/codegen/server_interface.h:212)
>>> grpc::ServerInterface::RequestAsyncCall<OpenIoTServer::EnrollRequest>(grpc::ServerInterface
>>>  
>>> * const this, grpc::internal::RpcServiceMethod * method, 
>>> grpc::ServerContext * context, 
>>> grpc::internal::ServerAsyncStreamingInterface * stream, 
>>> grpc::CompletionQueue * call_cq, grpc::ServerCompletionQueue * 
>>> notification_cq, void * tag, OpenIoTServer::EnrollRequest * message) 
>>> (/usr/local/include/grpcpp/impl/codegen/server_interface.h:275)
>>> grpc::Service::RequestAsyncUnary<OpenIoTServer::EnrollRequest>(grpc::Service
>>>  
>>> * const this, int index, grpc::ServerContext * context, 
>>> OpenIoTServer::EnrollRequest * request, 
>>> grpc::internal::ServerAsyncStreamingInterface * stream, 
>>> grpc::CompletionQueue * call_cq, grpc::ServerCompletionQueue * 
>>> notification_cq, void * tag) 
>>> (/usr/local/include/grpcpp/impl/codegen/service_type.h:96)
>>> OpenIoTServer::Device::WithAsyncMethod_Enroll<OpenIoTServer::Device::Service>::RequestEnroll(OpenIoTServer::Device::WithAsyncMethod_Enroll<OpenIoTServer::Device::Service>
>>>  
>>> * const this, grpc::ServerContext * context, OpenIoTServer::EnrollRequest * 
>>> request, grpc::ServerAsyncResponseWriter<OpenIoTServer::EnrollResponse> * 
>>> response, grpc::CompletionQueue * new_call_cq, grpc::ServerCompletionQueue 
>>> * notification_cq, void * tag) 
>>> (/home/developer/deployment-management-controller/device.grpc.pb.h:170)
>>> main() (/home/developer/deployment-management-controller/main.cpp:81)
>>>
>>> I've simplified my code as much as possible and the problem is still 
>>> occurring:
>>> #include "device.grpc.pb.h"
>>> #include <string>
>>> #include <boost/fiber/algo/algorithm.hpp>
>>> #include <grpcpp/grpcpp.h>
>>> #include <boost/thread.hpp>
>>> #include <boost/fiber/scheduler.hpp>
>>>
>>> using grpc::ServerAsyncResponseWriter;
>>> using grpc::ServerBuilder;
>>> using grpc::ServerContext;
>>> using grpc::ServerCompletionQueue;
>>> using grpc::Status;
>>>
>>> int main( int, char** )
>>> {
>>> std::unique_ptr<ServerCompletionQueue> cq_;
>>> OpenIoTServer::Device::AsyncService service_;
>>> std::unique_ptr<Server> server_;
>>>
>>> ServerBuilder serverBuilder;
>>> serverBuilder.AddListeningPort( "127.0.0.1:1000", 
>>> InsecureServerCredentials() );
>>> serverBuilder.RegisterService( &service_ );
>>>
>>> cq_ = serverBuilder.AddCompletionQueue();
>>> server_ = serverBuilder.BuildAndStart();
>>> ServerContext ctx_;
>>> EnrollRequest request_;
>>> EnrollResponse reply_;
>>> ServerAsyncResponseWriter<EnrollResponse> responder_(&ctx_);
>>>
>>> service_.RequestEnroll(&ctx_, &request_, &responder_, cq_.get(), cq_.get
>>> (),(void*)1); // SEGFAULT WITHIN HERE
>>> }
>>>
>>> My protobuf is generated from the following using protoc version 3.5.1:
>>> syntax = "proto3";
>>> package OpenIoTServer;
>>>
>>> service Device
>>> {
>>> rpc Enroll(EnrollRequest) returns (EnrollResponse);
>>> }
>>>
>>> message EnrollRequest
>>> {
>>> bytes device_id = 1;
>>> bytes user_id = 2;
>>> }
>>>
>>> message EnrollResponse
>>> {
>>> bool success = 1;
>>> }
>>>
>>> Any suggestions would be very-much appreciated!
>>>
>>> Many thanks
>>>
>>> -- 
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/grpc-io.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/grpc-io/6cea7726-cc2b-4ea0-bdcf-1a38f6301e43%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/grpc-io/6cea7726-cc2b-4ea0-bdcf-1a38f6301e43%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/c7f445c0-0f09-4f11-8f6a-c599298fd454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to