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 F3898200AF5 for ; Thu, 2 Jun 2016 20:19:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F21EE160A51; Thu, 2 Jun 2016 18:19: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 44568160A3E for ; Thu, 2 Jun 2016 20:19:04 +0200 (CEST) Received: (qmail 67178 invoked by uid 500); 2 Jun 2016 18:19:03 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 67167 invoked by uid 99); 2 Jun 2016 18:19:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 18:19:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id A4CE3C06CD for ; Thu, 2 Jun 2016 18:19:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.448 X-Spam-Level: X-Spam-Status: No, score=-6.448 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Tg0f42Z4JfSZ for ; Thu, 2 Jun 2016 18:19:01 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 8A6E55FB27 for ; Thu, 2 Jun 2016 18:19:01 +0000 (UTC) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA3DAC04B309 for ; Thu, 2 Jun 2016 18:19:00 +0000 (UTC) Received: from ovpn-116-181.phx2.redhat.com (ovpn-116-181.phx2.redhat.com [10.3.116.181]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u52IIxfb031995 for ; Thu, 2 Jun 2016 14:19:00 -0400 Message-ID: <1464891539.16213.96.camel@redhat.com> Subject: Re: [Proton-C - 0.12.2] C++ vector subscript out of range in unit tests From: Alan Conway To: users@qpid.apache.org Date: Thu, 02 Jun 2016 14:18:59 -0400 In-Reply-To: <1464890833.3372.52.camel@redhat.com> References: <1464888563150-7644983.post@n2.nabble.com> <1464890833.3372.52.camel@redhat.com> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 Jun 2016 18:19:00 +0000 (UTC) archived-at: Thu, 02 Jun 2016 18:19:05 -0000 On Thu, 2016-06-02 at 14:07 -0400, Andrew Stitcher wrote: > On Thu, 2016-06-02 at 10:29 -0700, Adel Boutros wrote: > > > > Hello, > > > > While compiling the unit tests of Proton-c 0.12.2 on Visual Studio > > 2008 in > > Debug mode, the cpp_scalar_test and cpp_value_test are failing with > > the > > error: "C++ vector subscript out of range"  > > After debugging, It seems that we try to cast the first element of > > a > > vector > > and the test has an empty vector which is causing the issue. > > > > The test fails for the following values: > > > >     try { coerce(V(binary())); FAIL("binary as symbol"); } > > catch > > (conversion_error) {} > >     try { coerce(V(symbol())); FAIL("symbol as binary"); } > > catch > > (conversion_error) {} > >     try { get(V(std::string())); FAIL("string as symbol"); > > } > > catch > > (conversion_error) {} > >     try { get(V(binary())); FAIL("binary as string"); > > } > > catch > > (conversion_error) {} > >     try { get(V(symbol())); FAIL("symbol as binary"); } > > catch > > (conversion_error) {} > > > > string, binary and symbol default constructor will construct an > > empty > > vector. > > > > So in types_internal.hpp, we do: pn_bytes_t b = { s.size(), > > reinterpret_cast(&s[0]) }; > > "s" is the empty vector so "s[0]" will throw the exception observed > > > > I have done a workaround  in the attached patch and the test is > > green > > now. > > But I think a clean fix is needed to prevent such error in > > production > > mode, > > no? > Yeah, I don't think there is much point in shipping that work around. > The test is functioning as required after all - it is failing when it > should. So making it pass would be wrong. Agreed, it's the impl not the test that needs fixing. I'll add a fix to  PROTON-1216: c++: proton::coerce() should allow conversion from binary. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org For additional commands, e-mail: users-help@qpid.apache.org