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 2C265200C09 for ; Tue, 10 Jan 2017 15:49:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2AE2E160B3D; Tue, 10 Jan 2017 14:49:00 +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 6FC13160B29 for ; Tue, 10 Jan 2017 15:48:59 +0100 (CET) Received: (qmail 40361 invoked by uid 500); 10 Jan 2017 14:48:58 -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 40338 invoked by uid 99); 10 Jan 2017 14:48:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2017 14:48:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 6E6F92C1F54 for ; Tue, 10 Jan 2017 14:48:58 +0000 (UTC) Date: Tue, 10 Jan 2017 14:48:58 +0000 (UTC) From: "Jens Geyer (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (THRIFT-4024) C# deserialization takes unnecessary time on list with unknown type of elements MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 10 Jan 2017 14:49:00 -0000 [ https://issues.apache.org/jira/browse/THRIFT-4024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15815139#comment-15815139 ] Jens Geyer edited comment on THRIFT-4024 at 1/10/17 2:48 PM: ------------------------------------------------------------- Under which circumstances can we run into a unknown type? The Thrift type system is well-defined, there should not be an unknown type at all. Can we have a test case? {quote} you may end up waiting for a random period of time until deserialization is completed (734707176 iterations of skipping in my case). {quote} What does random mean? Is that related to the number of items or why does it take 734 mio iterations? Where does that number come from? Please explain. was (Author: jensg): Under which circumstances can we run into a unknown type? The Thrift type system is well-defined, there should not be an unknown type at all. Can we have a test case? > C# deserialization takes unnecessary time on list with unknown type of elements > ------------------------------------------------------------------------------- > > Key: THRIFT-4024 > URL: https://issues.apache.org/jira/browse/THRIFT-4024 > Project: Thrift > Issue Type: Bug > Components: C# - Library > Affects Versions: 0.10.0 > Reporter: Michael Antipin > Assignee: Jens Geyer > > I'm using TBinaryProtocol and a simple transport that reads from a given byte array. > C# library contains the following code in TProtocolUtil.Skip(TProtocol prot, TType type): > {code} > case TType.List: > TList list = prot.ReadListBegin(); > for (int i = 0; i < list.Count; i++) { > Skip(prot, list.ElementType); > } > prot.ReadListEnd(); > break; > {code} > The type of elements is detected in ReadListBegin(), and, as Skip() does nothing for unknown types, the position in the binary remains the same until the for loop completes. > So, when you try to deserialize invalid data, and a field type happens to be detected as TType.List, you may end up waiting for a random period of time until deserialization is completed (734707176 iterations of skipping in my case). > I suggest throwing an exception immediately when list elements type is unknown. May be, it would be good to have a setting like *FailOnUnknownType*, so that Skip() will throw instead of ignoring. -- This message was sent by Atlassian JIRA (v6.3.4#6332)