Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 76588 invoked from network); 20 Mar 2008 19:02:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2008 19:02:55 -0000 Received: (qmail 44291 invoked by uid 500); 20 Mar 2008 19:02:53 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 44278 invoked by uid 500); 20 Mar 2008 19:02:53 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 44268 invoked by uid 99); 20 Mar 2008 19:02:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 12:02:53 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 19:02:01 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m2KJ2JJF012506 for ; Thu, 20 Mar 2008 19:02:19 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: _RWSTD_REQUIRES throwing uncaught exceptions in tests? Date: Thu, 20 Mar 2008 13:02:53 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: _RWSTD_REQUIRES throwing uncaught exceptions in tests? Thread-Index: AciKoMPveCnLGUUeRUKwjBKn3UQjAQAGKUsg References: <47E28302.8080608@roguewave.com> <47E284DF.4060009@roguewave.com> From: "Eric Lemings" To: X-Virus-Checked: Checked by ClamAV on apache.org =20 Interesting. I boiled these observations down to a simple little test case. [user@host exceptions]$ cat lib1.cpp #include #define STRINGIZE(x) _STRINGIZE(x) #define _STRINGIZE(x) #x void f () { const char* s =3D "file " __FILE__ ", line " STRINGIZE(__LINE__); throw std::out_of_range (s); } [user@host exceptions]$ cat prg.cpp #include #include extern void f (); int main () { try { f (); } catch (std::out_of_range& exc) { std::cerr << exc.what() << std::endl; } return 0; } [user@host exceptions]$ make lib g++ -g -Wall -c -o lib1.o lib1.cpp g++ -dynamiclib -install_name libfoo.dylib lib1.o -o libfoo.dylib [user@host exceptions]$ make prg g++ -g -Wall -c -o prg.o prg.cpp g++ -o prg prg.o -L. -lfoo [user@host exceptions]$ gdb ./prg GNU gdb 6.3.50-20050815 (Apple version gdb-573) (Fri Oct 20 15:50:43 GMT 2006) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries ..... done (gdb) break main Breakpoint 1 at 0x2d6d: file prg.cpp, line 9. (gdb) run Starting program: /Users/user/Developer/Tests/exceptions/prg Reading symbols for shared libraries .+ done Breakpoint 1, main () at prg.cpp:9 9 f (); (gdb) cont Continuing. file lib1.cpp, line 8 Program exited normally. It may be a little too simple but it works as expected. Brad. > -----Original Message----- > From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor > Sent: Thursday, March 20, 2008 9:38 AM > To: dev@stdcxx.apache.org > Subject: Re: _RWSTD_REQUIRES throwing uncaught exceptions in tests? >=20 > Martin Sebor wrote: > > There are some platforms where an exception thrown from a shared > > lib can't be caught in another executable. I vaguely recall that > > OS X may be one of them (maybe only under certain conditions). >=20 > FWIW, here's some background on this issue I found online: > http://lists.apple.com/archives/xcode-users/2006/Feb/msg00049.html > http://www.dribin.org/dave/blog/archives/2006/02/10/gcc_exception_bug/ > http://gcc.gnu.org/ml/gcc-help/2007-10/msg00239.html > http://tinyurl.com/2vx7rc >=20 > >=20 > > Martin > >=20 > > Eric Lemings wrote: > >> =20 > >> > >>> -----Original Message----- > >>> From: Travis Vitek [mailto:Travis.Vitek@roguewave.com] Sent:=20 > >>> Wednesday, March 19, 2008 10:50 PM > >>> To: dev@stdcxx.apache.org > >>> Subject: RE: _RWSTD_REQUIRES throwing uncaught exceptions=20 > in tests? > >>> > >>> > >>> > >>>> Eric Lemings wrote: > >>>> > >>>> Greetings, > >>>> =20 > >>>> I've been stepping through one of the string tests. The > >>>> std::string::at() member function is being called with a=20 > __pos value > >>>> that is >=3D size() causing the _RWSTD_REQUIRES assertion=20 > to fail. It > >>>> seems to be throwing an exception, which is not being=20 > caught, as a > >>>> result. Consequently, the whole test program raises an=20 > ABRT signal. > >>>> There are several such programs raising ABRT signals (on the Mac > >>>> platform at least). > >>>> > >>> Yeah, I looked at the build results for 21.string.access, and it=20 > >>> doesn't appear to be failing for this same reason on any other=20 > >>> platforms. > >>> > >>> One thing I noticed while looking at this is that the=20 > X-Platform view=20 > >>> doesn't show all tests. As an example, the 21.string.access test=20 > >>> appears in all of the standard results pages=20 > >>> [http://people.apache.org/~sebor/stdcxx/results/], but it doesn't=20 > >>> appear in the X-Platform view=20 > >>> [http://people.apache.org/~sebor/stdcxx/results/builds].=20 > Maybe this=20 > >>> is something that Martin should look at. Martin? > >>> =20 > >>>> Now there's certainly nothing wrong with the test case testing > >>>> out-of-bounds behavior but it should be catching any possible > >>>> exceptions, shouldn't it? Assuming the=20 > std::string::at() function > >>>> does not have a no-throw guarantee. > >>>> > >>> I'm assuming that you are asking why there is no catch=20 > (...) block to=20 > >>> eat all exceptions. I don't really have a good answer for that. > >>> > >>> I think that since the string implementation is only supposed to=20 > >>> throw std::length_error and std::out_of_range, it may be=20 > acceptable=20 > >>> to catch only those exceptions in the test for string. Of=20 > course some=20 > >>> other exception may be thrown indirectly [ex.=20 > >>> std::allocator::allocate() may throw std::bad_alloc],=20 > but those=20 > >>> cases should probably not be exercised by the string test. > >>> > >>> If the problem is what I think it is, adding a catch all probaly=20 > >>> won't help. I'm _guessing_ that the definition of std::exception=20 > >>> [which is based on output of config tests] isn't=20 > consistent with what=20 > >>> is provided by the runtime library. > >> > >> Actually there is a catch block. After digging some more,=20 > I believe > >> the problem is that another exception is being thrown while the > >> first out_of_range exception is being constructed. > >> > >> I noticed a buffer overrun for the __rw_what_buf array. =20 > Its size is > >> 256 characters (src/exception.cpp, line 436) but the string it held > >> was way more than this. (Need to replace that hard-coded=20 > 256 constant > >> with a macro define at least.) I increased its size but=20 > that didn't > >> solve the problem. I do know that the what argument (passed to the > >> _C_assign() function) is getting corrupted (overwritten) with junk > >> at some point. > >> > >> Still digging... > >> > >> Brad. > >> > >=20 > >=20 >=20 >=20