Skip to content

arrow::flight::FlightClient::AuthenticateBasicToken C++ Segmentation fault (core dumped) #37033

@geyungjen

Description

@geyungjen

Describe the bug, including details regarding any error messages, version, and platform.

My Arrow version is just installed on 8/6/2023:

https://github.com/apache/arrow

Here are some lines of my code for the client in C++:

_ARROW_ASSIGN_OR_RAISE(auto location, Location::ForGrpcTcp("10.0.0.103", 8904));
std::cout << "location " << location.ToString() <<  std::endl;

// Setup the Flight SQL Client
   std::unique_ptr<flight::FlightClient> client;
   ARROW_ASSIGN_OR_RAISE(client, flight::FlightClient::Connect(location));
   std::unique_ptr<arrow::flight::sql::FlightSqlClient> sql_client(
   new arrow::flight::sql::FlightSqlClient(std::move(client)));

   FlightCallOptions call_options;
   call_options.headers.emplace_back("authorization", "Basic");
   call_options.headers.emplace_back("database", "public");

   auto user = "sysdba";
   auto password = "passw0rd";

  **auto auth = client->AuthenticateBasicToken(call_options,user,password );
 //Segmentation Fault at the Above AuthenticateBasicToken call.**_

Valgrind shows below:

==5046== Invalid read of size 1
==5046==    at 0x4ABF7E1: arrow::flight::FlightClient::CheckOpen() const (client.cc:716)
==5046==    by 0x4ABDC12: arrow::flight::FlightClient::AuthenticateBasicToken(arrow::flight::FlightCallOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (client.cc:555)
==5046==    by 0x1159B9: main::{lambda()#1}::operator()() const (in /home/alice/arrow_notes/flightsql/build/arrow_flight_cpp)
==5046==    by 0x1163C8: main (in /home/alice/arrow_notes/flightsql/build/arrow_flight_cpp)
==5046==  Address 0x8 is not stack'd, malloc'd or (recently) free'd

It points to [OpenCheck() in client.cc](arrow::flight::FlightClient::CheckOpen() const (client.cc:716))
from arrow::flight::FlightClient::AuthenticateBasicToken(arrow::flight::FlightCallOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (client.cc:555)

At the line 716 in client.cc:

Status FlightClient::CheckOpen() const {
  if (closed_) {
    return Status::Invalid("FlightClient is closed");
  }
  return Status::OK();
}

Segmentation Fault occurred at: line 555 in same client.cc:

arrow::Result<std::pair<std::string, std::string>> FlightClient::AuthenticateBasicToken(
    const FlightCallOptions& options, const std::string& username,
    const std::string& password) {
  RETURN_NOT_OK(CheckOpen());  //Here is line 555, core dump starts here.
  return transport_->AuthenticateBasicToken(options, username, password);
}

Wondering why it is an invalid read?

==5046== Invalid read of size 1
==5046==    at 0x4ABF7E1: arrow::flight::FlightClient::CheckOpen() const (client.cc:716)
==5046==    by 0x4ABDC12: arrow::flight::FlightClient::AuthenticateBasicToken(arrow::flight::FlightCallOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (client.cc:555)
==5046==    by 0x1159B9: main::{lambda()#1}::operator()() const (in /home/alice/arrow_notes/flightsql/build/arrow_flight_cpp)
==5046==    by 0x1163C8: main (in /home/alice/arrow_notes/flightsql/build/arrow_flight_cpp)
==5046==  Address 0x8 is not stack'd, malloc'd or (recently) free'd

Thanks

George Jen

Component(s)

C, C++, FlightRPC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions