[ 
https://issues.apache.org/jira/browse/THRIFT-4225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16525000#comment-16525000
 ] 

ASF GitHub Bot commented on THRIFT-4225:
----------------------------------------

jeking3 closed pull request #1565: THRIFT-4225: Delete callback if RPC send 
failed
URL: https://github.com/apache/thrift/pull/1565
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc 
b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index 512fe3c1ff..57baa9b76d 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -1613,10 +1613,11 @@ void t_js_generator::generate_service_client(t_service* 
tservice) {
     indent_down();
     f_service_ << indent() << "}" << endl;
 
-    // Reset the transport if there was a serialization error
+    // Reset the transport and delete registered callback if there was a 
serialization error
     f_service_ << indent() << "catch (e) {" << endl;
     indent_up();
     if (gen_node_) {
+      f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl;
       f_service_ << indent() << "if (typeof " << outputVar << ".reset === 
'function') {" << endl;
       f_service_ << indent() << "  " << outputVar << ".reset();" << endl;
       f_service_ << indent() << "}" << endl;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Error handling malformed arguments leaks memory, corrupts transport buffers 
> causing next RPC to fail
> ----------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-4225
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4225
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Compiler, Node.js - Library
>    Affects Versions: 0.10.0
>            Reporter: Paul Taylor
>            Assignee: James E. King III
>            Priority: Major
>             Fix For: 0.12.0
>
>
> This issue is related to 
> [THRIFT-2997|https://issues.apache.org/jira/browse/THRIFT-2997]. I have a 
> workaround 
> [here|https://github.com/graphistry/rxjs-mapd/blob/bf88da285ebc32ee6528f596919c626efccaf7ee/src/client/bind.ts#L85],
>  but it's only possible because I'm wrapping all thrift client calls anyway.
> If the arguments to a thrift client method are malformed, the transport 
> throws an error while writing the arguments to its buffers. Unfortunately, 
> the buffers aren't reset (as would happen in flush), and the next RPC call 
> will fail if any values were already written. Additionally, the callback 
> isn't dereferenced from the client's _reqs table, leaking memory.
> From what I understand, this problem would need to be addressed in both the 
> node lib and compiler.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to