Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc library crashes when start watching cronet channel state #16381

Closed
mqingli opened this issue Aug 17, 2018 · 5 comments
Closed

grpc library crashes when start watching cronet channel state #16381

mqingli opened this issue Aug 17, 2018 · 5 comments

Comments

@mqingli
Copy link

mqingli commented Aug 17, 2018

What version of gRPC and what language are you using?

v1.11.0 C++

What operating system (Linux, Windows, …) and version?

IOS 11.4.1

What runtime / compiler are you using (e.g. python version or version of gcc)

gcc Apple LLVM version 9.1.0 (clang-902.0.39.2)

What did you do?

If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful.
create a cronet channel and call its NotifyOnStateChange to watch channel state:

std::shared_ptr<grpc::ChannelCredentials> cronetChannelCredentials = 
grpc::CronetChannelCredentials([Cronet getGlobalEngine]);
auto channel = grpc::CreateChannel(target, cronetChannelCredentials);
channel->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, cq, tag)  <== app crashes at this point

What did you expect to see?

NotifyOnStateChange returns the tag on cq when the channel state is changed or deadline expires.

What did you see instead?

app crashes at https://github.com/grpc/grpc/blob/master/src/core/ext/filters/client_channel/channel_connectivity.cc#L246
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment?

The code is called in C++ native library from IOS app.

@muxi
Copy link
Member

muxi commented Aug 20, 2018

@mqingli - Did it work for you before? The C++ API surprises me a bit since I thought on grpc c++ Cronet just links to a dummy interface. How are you linking Cronet?

@gcasto - I see you added the c++ API a while ago. Is it supposed to work? Is it not using this fake interface on github?

@mqingli
Copy link
Author

mqingli commented Aug 20, 2018

@muxi thanks for your response. we linked with grpc.a, grpc++.a, grpc_cronet.a and grpc++_cronet.a in our C++ library. RPC call via cronet channel works. But grpc library errored out or crashed as long as we call cronet channel's NotifyOnStateChange or getState.Briefly checked the related grpc library code, looks like cronet channel has the GRPC_CLIENT_DIRECT_CHANNEL type. It doesn't not registered with grpc_client_channel_filter filter, which handles channel state.

If this doesn't work, I'm wondering any alternative way that we can watch cronet channel state?

@muxi
Copy link
Member

muxi commented Aug 20, 2018

Thanks for the info. It is interesting to see rpc call works.

You are right that direct channel is not associated with client channel filter since the channel is not a gRPC managed channel. Cronet manages channels by itself which is transparent to gRPC. Cronet API does not provide that information.

If you could share us your crash stack with us, we might confirm that was the reason of the crash and make the API work better than simply crashing, but I'm afraid the channel state information is not available.

@mqingli
Copy link
Author

mqingli commented Aug 22, 2018

Hi @muxi , sorry for the late reply. Here is the crash stack from grpc library.

#0 0x000000018381d2e0 in __pthread_kill ()
#1 0x00000001839be288 in pthread_kill$VARIANT$mp ()
#2 0x000000018378bd0c in abort ()
#3 0x00000001060a66c8 in ::grpc_channel_watch_connectivity_state(grpc_channel *, grpc_connectivity_state, gpr_timespec, grpc_completion_queue , void ) at grpc/src/core/ext/filters/client_channel/channel_connectivity.cc:246
#4 0x00000001082d0940 in void grpc::ChannelInterface::NotifyOnStateChange<std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> > > >(grpc_connectivity_state, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> > >, grpc::CompletionQueue
, void
) at grpcpp/impl/codegen/channel_interface.h:68

#5 client function calling channel->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, cq, tag)

@muxi
Copy link
Member

muxi commented Mar 28, 2019

Sorry for missing the message for so long, but (as you probably already find out) Cronet does not support the connectivity_state watch. Closing this issue unless there's other concern being raised.

@muxi muxi closed this as completed Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants