#1080 STLport stl_unit_test fails with "terminate called after..."

OTHER
closed
nobody
gcc (462)
none
User_Error
2014-08-18
2007-09-09
No

See also: https://sourceforge.net/forum/message.php?msg_id=4508032

* OS version:
Windows Server 2003 Enterprise R2 SP1 with all recent updates

* gcc version( `gcc -v` ):
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.2.1-2-src/configure --with-gcc --enable-libgomp --host=mingw32 --build=mingw32 --target=mingw32 --program-suffix=-dw2 --with-arch=i486 --with-tune=generic --disable-werror --prefix=/mingw --with-local-prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-win32-registry --disable-sjlj-exceptions --enable-libstdcxx-debug --enable-cxx-flags=-fno-function-sections -fno-data-sections --enable-version-specific-runtime-libs --disable-bootstrap
Thread model: win32
gcc version 4.2.1-dw2 (mingw32-2)

* ld version( `ld -v` ):
GNU ld version 2.17.50 20070129

* mingw version ( name of installer package eg/ MinGW-2.0.0-3.exe )
manually unpacked

* build environment:
msysCORE-1.0.11-2007.01.19-1.tar.bz2
MSYS-1.0.11-20070729.tar.bz2
bash-3.1-MSYS-1.0.11-snapshot.tar.bz2
coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2

* if using MSYS version number ( `uname -a`)
MINGW32_NT-5.2 PC 1.0.11(0.46/3/2) 2007-07-29 17:16 i686 Msys

* mingw-runtime version ( include/_mingw.h)
3.13(mingw-runtime-3.13-20070825-1.tar.gz)

* w32api version ( include/w32api.h )
3.10

STLport-5.1.3 successfuly built(lib + tests), but tests(stl_unit_test) fails with this output:
$ stl_unit_test.exe
AccumTest::accum1
AccumTest::accum2
AdjTest::adjfind0
AdjTest::adjfind1
AdjTest::adjfind2
AdjTest::adjdiff0
AdjTest::adjdiff1
AdjTest::adjdiff2
AdvanceTest::adv
AlgTest::min_max
AlgTest::count_test
AlgTest::sort_test
AlgTest::search_n_test
AlgTest::find_first_of_test
AllocatorTest::zero_allocation
AllocatorTest::bad_alloc_test
BcomposTest::bcompos1
BcomposTest::bcompos2
BindTest::bind1st1
BindTest::bind2nd1
BindTest::bind2nd2
BindTest::bind2nd3
BindTest::bind_memfn
BinsertTest::binsert1
BinsertTest::binsert2
BitsetTest::bitset1
BnegateTest::bnegate1
BnegateTest::bnegate2
BoundTest::lwrbnd1
BoundTest::lwrbnd2
BoundTest::uprbnd1
BoundTest::uprbnd2
BsearchTest::bsearch1
BsearchTest::bsearch2
BvectorTest::bvec1
CMathTest::test
CodecvtTest::variable_encoding
ConfigTest::placement_new_bug
ConfigTest::endianess
ConfigTest::template_function_partial_ordering
CopyTest::copy_array
CopyTest::copy_vector
CopyTest::copy_insert
CopyTest::copy_back
CopyTest::copy_back_array
CountTest::count0
CountTest::count1
CountTest::countif1
DequeTest::deque1
DequeTest::at
terminate called after throwing an instance of 'stlp_std::out_of_range'
what(): deque

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I've discovered test cases.
Here are some helpful snippets.
// STLport-5.1.3/test/unit/deque_test.cpp lines 157-180
void DequeTest::at() {
deque<int> d;
deque<int> const& cd = d;

d.push_back(10);
CPPUNIT_ASSERT( d.at(0) == 10 );
d.at(0) = 20;
CPPUNIT_ASSERT( cd.at(0) == 20 );

#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
for (;;) {
try {
d.at(1) = 20; // here test-case trying to access out-of-range element.
CPPUNIT_ASSERT(false);
}
catch (std::out_of_range const&) {
return;
}
catch (...) {
CPPUNIT_ASSERT(false);
}
}
#endif
}

// STLport-5.1.3/stlport/stl/_deque.h lines 452-459
void _M_range_check(size_type __n) const {
if (__n >= this->size())
__stl_throw_out_of_range("deque"); // here exception should be thrown
}
reference at(size_type __n)
{ _M_range_check(__n); return (*this)[__n]; }
const_reference at(size_type __n) const
{ _M_range_check(__n); return (*this)[__n]; }

// STLport-5.1.3/stlport/stl/_range_errors.h lines 34-41
_STLP_BEGIN_NAMESPACE
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg);
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg);
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg);
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg);
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg);
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg);
_STLP_END_NAMESPACE

//STLport-5.1.3/src/dll_main.cpp lines 92-93
void _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg)
{ _STLP_THROW_MSG(out_of_range, __msg); } // after preprocessing it looks like this: { throw out_of_range(string(__msg)); }

It looks like 'terminate' called because exception left dll-module scope.

Discussion

  • Danny Smith

    Danny Smith - 2007-09-09

    Logged In: YES
    user_id=11494
    Originator: NO

    If you want to throw exceptions across a dll boundary you need to build dll and client exe with --shared-libgcc. Or port the mingw-specific gcc-3.4.5 -win32-shared-ptr patches to gcc 4.x

    Danny

     
  • Earnie Boyd

    Earnie Boyd - 2012-10-24
    • labels: --> gcc
    • milestone: --> Aged_issue
    • status: open --> closed-out-of-date
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-29
    • status: closed-out-of-date --> closed
    • resolution: --> none
    • category: --> User_Error
    • milestone: --> OTHER
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks