[ https://issues.apache.org/jira/browse/THRIFT-5507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17484353#comment-17484353 ]
Jens Geyer edited comment on THRIFT-5507 at 1/30/22, 1:12 PM: -------------------------------------------------------------- If you happen to have a patch ready - [please send a PR|https://thrift.apache.org/docs/HowToContribute. Would be great to include this in 0.16.0 was (Author: jensg): If you happen to have a patch ready - please send a PR. Would be great to include this in 0.16.0 > C++ clients crash when exceptions are defined in different IDL > -------------------------------------------------------------- > > Key: THRIFT-5507 > URL: https://issues.apache.org/jira/browse/THRIFT-5507 > Project: Thrift > Issue Type: Bug > Components: C++ - Compiler > Affects Versions: 0.14.0, 0.15.0 > Environment: CentOS Linux release 7.6.1810 (Core) > Reporter: wangguitao > Priority: Major > > 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;* > *{color:#de350b}MyException e;{color}* > *{_}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;* > *{color:#de350b}MyException* e;{color}* > *{_}MyResource_QueryMyResource_presult{_}{_}isset{_} _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) { > {color:#de350b}{*}xfer += ({*}(this->e)).read(iprot);*{color} > this->__isset.e = true; > } else > { xfer += iprot->skip(ftype); } > the MyResource_QueryMyResource_presult field e isn't allocated memory, so > client core dump. > > -- This message was sent by Atlassian Jira (v8.20.1#820001)