Hi

I have written a small asynchronous gRPC server, but sometimes I get a 
strange *memory access violation* inside gRPC code after finishing a 
request. I get the exception in **AsyncNextInternal**:
CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
    void** tag, bool* ok, gpr_timespec deadline) {
  for (;;) {
    auto ev = grpc_completion_queue_next(cq_, deadline, nullptr);
    switch (ev.type) {
      case GRPC_QUEUE_TIMEOUT:
        return TIMEOUT;
      case GRPC_QUEUE_SHUTDOWN:
        return SHUTDOWN;
      case GRPC_OP_COMPLETE:
        auto core_cq_tag =
            static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag);
        *ok = ev.success != 0;
        *tag = core_cq_tag;
        if (core_cq_tag->FinalizeResult(tag, ok)) { // <<-- Here
          return GOT_EVENT;
        }
        break;
    }
  }
}
It happens because *core_cq_tag* will be a dangling pointer and 
dereferencing this pointer for calling *FinalizeResult()* creates a memory 
access violation. This this is an internal pointer and not what I provide 
as tag, any idea why this may happen? I'm using gRPC 1.27.3 and I have both 
*Alarm 
*and *AsyncNotifyWhenDone()* registered for my connection info and I delete 
my own corresponding data when *AsyncNotifyWhenDone()* callback is called.
As an additional question, what happens if a CompletionQueue is shutdown 
before a registered alarm expires? will this alarm be ignored or be 
delivered? 

Best Regards

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/afa4d595-10ab-46dc-ad5b-63cb107107a8%40googlegroups.com.

Reply via email to