Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5507

C++ clients crash when exceptions are defined in different IDL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.14.0, 0.15.0
    • None
    • C++ - Compiler
    • None
    • CentOS Linux release 7.6.1810 (Core) 

    Description

      1st, I define a simple test.thrift file, as follow

      exception MyException {
          1:required i32 code;
          2:optional string message;
      }

      service MyResource {
          i32 QueryMyResource() throws(1:MyException e);
      }

      generate source code
      class MyResource_QueryMyResource_presult {
       public:
        virtual ~MyResource_QueryMyResource_presult() noexcept;
        int32_t success;*
        MyException e;

        MyResource_QueryMyResource_presult_isset __isset;
        uint32_t read(::apache::thrift::protocol::TProtocol iprot);*
      };
       

      2nd, I move MyException to other file, as follow

      test.thrift

      namespace cpp MySpace
      include "testc.thrift"

      typedef testc.MyException MyException

      service MyResource {
          i32 QueryMyResource() throws(1:MyException e);
      }

      testc.thrift

      exception MyException {
          1:required i32 code;
          2:optional string message;
      }

      generate source code
      class MyResource_QueryMyResource_presult {
       public:

        virtual ~MyResource_QueryMyResource_presult() noexcept;
        int32_t success;*
        MyException* e;

        MyResource_QueryMyResource_presultisset _isset;

        uint32_t read(::apache::thrift::protocol::TProtocol iprot);*

      };
       

      and when client using the interface, client core dump, the core occur in 
      funciton uint32_t MyResource_QueryMyResource_presult::read, mark with red line
            case 1:
              if (ftype == ::apache::thrift::protocol::T_STRUCT) {
                xfer += ((this->e)).read(iprot);*
                this->__isset.e = true;
              } else 

      {           xfer += iprot->skip(ftype);         }

      the MyResource_QueryMyResource_presult field e isn't allocated memory, so client core dump.
       
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            wangguitao wangguitao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: