disabling the non-intrusive exception_ptr support in tests, seems buggy..

[SVN r65161]
This commit is contained in:
Emil Dotchevski
2010-09-01 07:59:35 +00:00
parent 17304c365c
commit 5dbd4c8f32
4 changed files with 44 additions and 36 deletions

View File

@ -5,7 +5,7 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying # Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
lib boost_exception ; alias boost_exception ;
lib boost_exception : ../src/clone_current_exception_msvc.cpp : <toolset>msvc ; lib boost_exception : ../src/clone_current_exception_msvc.cpp : <toolset>msvc ;
boost-install boost_exception ; boost-install boost_exception ;

View File

@ -72,7 +72,8 @@ namespace
class_has_virtual_base=4 class_has_virtual_base=4
}; };
struct cpp_type_info struct
cpp_type_info
{ {
unsigned flags; unsigned flags;
void const * type_info; //std::type_info * type_info; void const * type_info; //std::type_info * type_info;
@ -103,9 +104,11 @@ namespace
exception_object_deleter exception_object_deleter
{ {
cpp_exception_type const * exception_type_; cpp_exception_type const * exception_type_;
bool run_destructor_;
exception_object_deleter( cpp_exception_type const * exception_type ): exception_object_deleter( cpp_exception_type const * exception_type, bool run_destructor ):
exception_type_(exception_type) exception_type_(exception_type),
run_destructor_(run_destructor)
{ {
BOOST_ASSERT(exception_type_!=0); BOOST_ASSERT(exception_type_!=0);
} }
@ -114,14 +117,17 @@ namespace
operator()( void * exception_object ) operator()( void * exception_object )
{ {
BOOST_ASSERT(exception_object!=0); BOOST_ASSERT(exception_object!=0);
if( run_destructor_ )
{
dummy_exception_type * dummy_exception_ptr=reinterpret_cast<dummy_exception_type *>(exception_object); dummy_exception_type * dummy_exception_ptr=reinterpret_cast<dummy_exception_type *>(exception_object);
(dummy_exception_ptr->*(exception_type_->destructor))(); (dummy_exception_ptr->*(exception_type_->destructor))();
}
free(exception_object); free(exception_object);
} }
}; };
boost::shared_ptr<void> boost::shared_ptr<void>
copy_msvc_exception( void * source_object, cpp_exception_type const * exception_type ) copy_msvc_exception( void * source_object, cpp_exception_type const * exception_type, bool run_destructor )
{ {
void * exception_object = malloc(exception_type->type_info_table->info[0]->size); void * exception_object = malloc(exception_type->type_info_table->info[0]->size);
if( !exception_object ) if( !exception_object )
@ -137,7 +143,7 @@ namespace
} }
else else
memmove(exception_object,source_object,type->size); memmove(exception_object,source_object,type->size);
return boost::shared_ptr<void>(exception_object,exception_object_deleter(exception_type)); return boost::shared_ptr<void>(exception_object,exception_object_deleter(exception_type,run_destructor));
} }
class class
@ -154,7 +160,7 @@ namespace
cloned_exception( void * source_object, cpp_exception_type const * exception_type ): cloned_exception( void * source_object, cpp_exception_type const * exception_type ):
exception_type_(exception_type), exception_type_(exception_type),
exception_object_(copy_msvc_exception(source_object,exception_type_)) exception_object_(copy_msvc_exception(source_object,exception_type_,true))
{ {
} }
@ -171,7 +177,7 @@ namespace
void void
rethrow() const rethrow() const
{ {
boost::shared_ptr<void const> clone=copy_msvc_exception(exception_object_.get(),exception_type_); boost::shared_ptr<void const> clone=copy_msvc_exception(exception_object_.get(),exception_type_,false);
ULONG_PTR args[cpp_exception_parameter_count]; ULONG_PTR args[cpp_exception_parameter_count];
args[0]=cpp_exception_magic_flag; args[0]=cpp_exception_magic_flag;
args[1]=reinterpret_cast<ULONG_PTR>(clone.get()); args[1]=reinterpret_cast<ULONG_PTR>(clone.get());
@ -181,7 +187,7 @@ namespace
}; };
bool bool
is_cpp_exception( EXCEPTION_RECORD * record ) is_cpp_exception( EXCEPTION_RECORD const * record )
{ {
return record && return record &&
(record->ExceptionCode==cpp_exception_code) && (record->ExceptionCode==cpp_exception_code) &&
@ -190,30 +196,27 @@ namespace
} }
unsigned long unsigned long
exception_cloning_filter( boost::exception_detail::clone_base const * * ptr, void * info_ ) exception_cloning_filter( int & result, boost::exception_detail::clone_base const * & ptr, void * info_ )
{ {
BOOST_ASSERT(ptr!=0);
BOOST_ASSERT(!*ptr);
BOOST_ASSERT(info_!=0); BOOST_ASSERT(info_!=0);
EXCEPTION_POINTERS * info=reinterpret_cast<EXCEPTION_POINTERS *>(info_); EXCEPTION_POINTERS * info=reinterpret_cast<EXCEPTION_POINTERS *>(info_);
EXCEPTION_RECORD * record=info->ExceptionRecord; EXCEPTION_RECORD * record=info->ExceptionRecord;
if( is_cpp_exception(record) ) if( is_cpp_exception(record) )
{ {
if( !record->ExceptionInformation[2] ) if( !record->ExceptionInformation[2] )
{
record = *reinterpret_cast<EXCEPTION_RECORD * *>(reinterpret_cast<char *>(_errno())+exception_info_offset); record = *reinterpret_cast<EXCEPTION_RECORD * *>(reinterpret_cast<char *>(_errno())+exception_info_offset);
}
if( is_cpp_exception(record) && record->ExceptionInformation[2] ) if( is_cpp_exception(record) && record->ExceptionInformation[2] )
try try
{ {
*ptr = new cloned_exception( ptr = new cloned_exception(
reinterpret_cast<void *>(record->ExceptionInformation[1]), reinterpret_cast<void *>(record->ExceptionInformation[1]),
reinterpret_cast<cpp_exception_type const *>(record->ExceptionInformation[2])); reinterpret_cast<cpp_exception_type const *>(record->ExceptionInformation[2]));
result = boost::exception_detail::clone_current_exception_result::success;
} }
catch( catch(
std::bad_alloc & ) std::bad_alloc & )
{ {
BOOST_ASSERT(!*ptr); result = boost::exception_detail::clone_current_exception_result::bad_alloc;
} }
catch( catch(
... ) ... )
@ -235,23 +238,22 @@ boost
clone_current_exception_msvc( clone_base const * & cloned ) clone_current_exception_msvc( clone_base const * & cloned )
{ {
BOOST_ASSERT(!cloned); BOOST_ASSERT(!cloned);
if( exception_info_offset<0 ) int result = clone_current_exception_result::not_supported;
return clone_current_exception_result::not_supported; if( exception_info_offset>=0 )
clone_base const * res=0; {
clone_base const * ptr=0;
__try __try
{ {
throw; throw;
} }
__except(exception_cloning_filter(&res,GetExceptionInformation())) __except(exception_cloning_filter(result,ptr,GetExceptionInformation()))
{ {
} }
if( !res ) if( result==clone_current_exception_result::success )
return clone_current_exception_result::bad_alloc; cloned=ptr;
else
{
cloned=res;
return clone_current_exception_result::success;
} }
BOOST_ASSERT(result!=clone_current_exception_result::success || cloned);
return result;
} }
} }
} }

View File

@ -7,7 +7,12 @@
import testing ; import testing ;
project : requirements <exception-handling>on <define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ; project
: requirements
<exception-handling>on
<source>/boost//exception
# <define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR
;
#to_string #to_string
@ -36,7 +41,7 @@ run refcount_ptr_test.cpp ;
run current_exception_cast_test.cpp ; run current_exception_cast_test.cpp ;
run no_exceptions_test.cpp : : : <exception-handling>off ; run no_exceptions_test.cpp : : : <exception-handling>off ;
run errinfos_test.cpp ; run errinfos_test.cpp ;
run exception_ptr_test.cpp /boost//thread /boost//exception : : : <threading>multi ; run exception_ptr_test.cpp /boost//thread : : : <threading>multi ;
compile-fail exception_fail.cpp ; compile-fail exception_fail.cpp ;
compile-fail throw_exception_fail.cpp ; compile-fail throw_exception_fail.cpp ;

View File

@ -84,7 +84,8 @@ exc:
++exc_count; ++exc_count;
} }
~exc() virtual
~exc() throw()
{ {
--exc_count; --exc_count;
} }