Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D84A1200CFC for ; Thu, 14 Sep 2017 07:15:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D76981609CB; Thu, 14 Sep 2017 05:15:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2973E1609CA for ; Thu, 14 Sep 2017 07:15:04 +0200 (CEST) Received: (qmail 23824 invoked by uid 500); 14 Sep 2017 05:15:03 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 23813 invoked by uid 99); 14 Sep 2017 05:15:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2017 05:15:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 95F91C2130 for ; Thu, 14 Sep 2017 05:15:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id xdVvC-JxgQjl for ; Thu, 14 Sep 2017 05:15:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 3971C5FE64 for ; Thu, 14 Sep 2017 05:15:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7FA9AE00C9 for ; Thu, 14 Sep 2017 05:15:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 372E625382 for ; Thu, 14 Sep 2017 05:15:00 +0000 (UTC) Date: Thu, 14 Sep 2017 05:15:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (THRIFT-4326) Ruby BufferedTransport not safe for reuse after reading corrupted input MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 14 Sep 2017 05:15:05 -0000 [ https://issues.apache.org/jira/browse/THRIFT-4326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16165759#comment-16165759 ] ASF GitHub Bot commented on THRIFT-4326: ---------------------------------------- Github user jeking3 commented on the issue: https://github.com/apache/thrift/pull/1352 Of course now I see job 2 is failing in nodejs as well. Spectacular! Well, let's see how this fares. If we can get job 4 to pass that would be ideal. If this one doesn't work I'll run it locally myself in docker and validate it before merging. > Ruby BufferedTransport not safe for reuse after reading corrupted input > ----------------------------------------------------------------------- > > Key: THRIFT-4326 > URL: https://issues.apache.org/jira/browse/THRIFT-4326 > Project: Thrift > Issue Type: Bug > Components: Ruby - Library > Affects Versions: 0.10.0 > Environment: Originally observed with Thrift 0.9.3 on Linux with Ruby 2.3.4, but have also reproduced on Mac OS X with Thrift 0.10.0. > Reporter: Ben Weintraub > > We've experimented with the Ruby {{BufferedTransport}} class as a wrapper around the {{HttpClientTransport}} class, and found that we were getting clusters sporadic {{Thrift::ProtocolException}} errors in Ruby client processes after network issues caused corruption of some Thrift response bodies. > Using a bare {{HttpClientTransport}} makes these issues disappear. > For a given service, we retain a long-lived protocol instance ({{CompactProtocol}} in our case), which in turn holds a reference to a long-lived {{BufferedTransport}} instance. > The problem seems to stem from the case where the Thrift client is interrupted (e.g. by a Ruby timeout exception) before consuming to the end of the {{@rbuf}} instance variable in {{BufferedTransport}}, leaving {{@index}} pointing to the middle of the read buffer, and meaning that when the transport is re-used upon the next service call, the {{BufferedTransport}} continues reading where it left off in the old buffer, rather than calling through to the wrapped {{HttpClientTransport}} to read the new response obtained from the last call to {{#flush}}. > Now I know {{Timeout}} is fundamentally unsafe in Ruby and can lead to all kinds of issues like this, but I've also found that this same issue can be triggered by another fairly plausible scenario: if the Thrift service returns a well-formed Thrift response but with N extra bytes of garbage tacked onto the end, then the next N following service calls through the same {{BufferedTransport}} instance will fail with a {{Thrift::ProtocolException}}, as the {{BufferedTransport}} will continue attempting to read the left-over bytes in {{@rbuf}}. > The naive solution seems like it would be to just reset {{@rbuf}} from {{#flush}}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)