From 25a658440dd6f66d64cc146a09ff0725d355bf5c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 25 Oct 2018 11:07:43 -0400 Subject: DRTVWR-476: Remove throw(T) from operator new(), operator delete(). llcorehttp's test_allocator.{h,cpp} overrides global operator new(), operator new[](), operator delete() and operator delete[](). The two operator new() functions used to be declared with throw(std::bad_alloc). Worse, for VS 2013 and previous, we needed _THROW0() and _THROW1(std::bad_alloc) instead, requiring #if logic. But with dynamic throw declarations deprecated, we must actually remove those. That obviates the THROW_BAD_ALLOC() / THROW_NOTHING() workarounds in test_allocator.cpp. --- indra/llcorehttp/tests/test_allocator.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'indra/llcorehttp/tests/test_allocator.h') diff --git a/indra/llcorehttp/tests/test_allocator.h b/indra/llcorehttp/tests/test_allocator.h index 3572bbc5c5..74bd294e47 100644 --- a/indra/llcorehttp/tests/test_allocator.h +++ b/indra/llcorehttp/tests/test_allocator.h @@ -31,17 +31,10 @@ #include size_t GetMemTotal(); -#if defined(WIN32) -void * operator new(std::size_t size) _THROW1(std::bad_alloc); -void * operator new[](std::size_t size) _THROW1(std::bad_alloc); -void operator delete(void * p) _THROW0(); -void operator delete[](void * p) _THROW0(); -#else -void * operator new(std::size_t size) throw (std::bad_alloc); -void * operator new[](std::size_t size) throw (std::bad_alloc); +void * operator new(std::size_t size); //throw (std::bad_alloc); +void * operator new[](std::size_t size); //throw (std::bad_alloc); void operator delete(void * p) throw (); void operator delete[](void * p) throw (); -#endif #endif // TEST_ALLOCATOR_H -- cgit v1.2.3 From 2902f23a4193d93c2e96daa45587a8c597c0a831 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 27 Jun 2019 10:57:34 -0400 Subject: DRTVWR-476: Remove special llcorehttp test memory manager. NickyD discovered that the substitute default allocator used for llcorehttp tests was returning badly-aligned storage, which caused access violations on alignment-sensitive data such as std::atomic. Thanks Nicky!! Moreover, the llcorehttp test assertions regarding memory usage, well- intentioned though they are, have been causing us trouble for years. Many have already been disabled. The problem is that use of test_allocator.h affected *everything* defined with that header file's declarations visible. That inevitably included specific functions in other subsystems. Those functions then (unintentionally) consumed the special allocator, throwing off the memory tracking and making certain memory-related assertions consistently fail. This is a particular, observable bad effect of One Definition Rule violations. Within a given program, C++ allows multiple definitions for the same entity, but requires that all such definitions be the same. Partial visibility of the global operator new() and operator delete() overrides meant that some definitions of certain entities used the default global allocator, some used llcorehttp's. There may have been other, more subtle bad effects of these ODR violations. If one wanted to reimplement verification of the memory consumption of llcorehttp classes: * Each llcorehttp class (for which memory tracking was desired) should declare class-specific operator new() and operator delete() methods. Naturally, these would all consume a central llcorehttp-specific allocator, but that allocator should *not* be named global operator new(). * Presumably that would require runtime indirection to allow using the default allocator in production while substituting the special allocator for tests. * Recording and verifying the memory consumption in each test should be performed in the test-object constructor and destructor, rather than being sprinkled throughout the test() methods. * With that mechanism in place, the test object should provide methods to adjust (or entirely disable) memory verification for a particular test. * The test object should also provide a "yes, we're still consuming llcorehttp memory" method to be used for spot checks in the middle of tests -- instead of sprinkling in explicit comparisons as before. * In fact, the llcorehttp test object in each test_*.hpp file should be derived from a central llcorehttp test-object base class providing those methods. --- indra/llcorehttp/tests/test_allocator.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llcorehttp/tests/test_allocator.h') diff --git a/indra/llcorehttp/tests/test_allocator.h b/indra/llcorehttp/tests/test_allocator.h index 74bd294e47..abd88f4c98 100644 --- a/indra/llcorehttp/tests/test_allocator.h +++ b/indra/llcorehttp/tests/test_allocator.h @@ -30,6 +30,8 @@ #include #include +#error 2019-06-27 Do not use test_allocator.h -- does not respect alignment. + size_t GetMemTotal(); void * operator new(std::size_t size); //throw (std::bad_alloc); void * operator new[](std::size_t size); //throw (std::bad_alloc); -- cgit v1.2.3