FRRouting / frr

The FRRouting Protocol Suite
https://frrouting.org/
Other
3.35k stars 1.26k forks source link

grpc call generate coredump #16298

Open nanfengnan1 opened 4 months ago

nanfengnan1 commented 4 months ago

Description

i want to frr capabilities. write a grpc client call, but coredump.

Version

frr-10.0

How to reproduce

include

include

include <grpc/grpc.h>

include <grpcpp/create_channel.h>

include "frr-northbound.pb.h"

include "frr-northbound.grpc.pb.h"

void get_capbilites_callback(grpc::Status status) { if (status.ok()) { std::cout << "RPC call succeeded!" << std::endl; } else { std::cout << "RPC call failed: " << status.error_message() << std::endl; } }

int main() { frr::GetRequest request; frr::GetResponse reply; grpc::ClientContext context; grpc::Status status;

/* 
 * grpc api: create a grpc channel for tcp connect 
 *      param1: ip:port pair
 *      param2: authentication credentials
 *              grpc::InsecureChannelCredentials: unsecurity connect
 *              grpc::SslCredentials: ssl/tll connect and recommand
 */
auto channel = grpc::CreateChannel("10.8.126.131:50051",
                                 grpc::InsecureChannelCredentials());
auto stub = frr::Northbound::NewStub(channel);

if 0

request.set_type(frr::GetRequest::ALL);
request.set_encoding(frr::XML);
request.set_with_defaults(true);
request.add_path("/frr-interface:lib");
auto stream = stub->Get(&context, request);

std::ostringstream ss;
while (stream->Read(&reply))
  ss << reply.data().data() << std::endl;

status = stream->Finish();
assert(status.ok());
std::cout << "Interface Info:\n" << ss.str() << std::endl;

std::cout << "service name: " << frr::Northbound::service_full_name() << std::endl;

std::cout << "" << std::endl;^

endif

frr::CreateCandidateRequest req_candidate;
frr::CreateCandidateResponse res_candidate;

status = stub->CreateCandidate(&context, req_candidate, &res_candidate);

assert(status.ok());
printf("create candidate, id: %u\n", res_candidate.candidate_id());

frr::GetCapabilitiesRequest req_cap;
frr::GetCapabilitiesResponse res_cap;

req_cap.InitAsDefaultInstance();

stub->GetCapabilities(&context, req_cap, &res_cap);

printf("frr_version: \"%s\"\n", res_cap.frr_version());
printf("support modules: %ld\n", res_cap.supported_modules_size());
printf("rollback_support: %d\n", res_cap.rollback_support());

}

g++ nrth_cpp_client.cc frr-northbound.grpc.pb.cc frr-northbound.pb.cc -o nrth_cpp_client -lgrpc++ -lprotobuf

Expected behavior

x

Actual behavior

callback stack: [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./nrth_cpp_client'. Program terminated with signal SIGABRT, Aborted.

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50

50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. [Current thread is 1 (Thread 0x7f07e2847240 (LWP 17649))] (gdb) bt

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50

1 0x00007f07e2e76859 in __GI_abort () at abort.c:79

2 0x00007f07e351c273 in ?? () from /lib/x86_64-linux-gnu/libgrpc++.so.1

3 0x00007f07e3522ce5 in grpc::Channel::CreateCall(grpc::internal::RpcMethod const&, grpc::ClientContext, grpc::CompletionQueue) () from /lib/x86_64-linux-gnu/libgrpc++.so.1

4 0x000055c16f7f74e9 in grpc::internal::BlockingUnaryCallImpl<frr::GetCapabilitiesRequest, frr::GetCapabilitiesResponse>::BlockingUnaryCallImpl(grpc::ChannelInterface, grpc::internal::RpcMethod const&, grpc::ClientContext, frr::GetCapabilitiesRequest const&, frr::GetCapabilitiesResponse*) ()

5 0x000055c16f7f2706 in grpc::Status grpc::internal::BlockingUnaryCall<frr::GetCapabilitiesRequest, frr::GetCapabilitiesResponse>(grpc::ChannelInterface, grpc::internal::RpcMethod const&, grpc::ClientContext, frr::GetCapabilitiesRequest const&, frr::GetCapabilitiesResponse*) ()

6 0x000055c16f7eb235 in frr::Northbound::Stub::GetCapabilities(grpc::ClientContext, frr::GetCapabilitiesRequest const&, frr::GetCapabilitiesResponse) ()

7 0x000055c16f7ea210 in main ()

hope to okay. i want to know if my function call error. hope to how to use frr grpc function call.

Additional context

x

Checklist

nanfengnan1 commented 4 months ago

i did't start sqlite3 database.