Skip to content

[Bug]: Leaked objects detected in example source #254

Description

@inhahe

Detailed steps on how to reproduce the bug

I ran examples\CMakeLists.txt with Visual Studio 2022, and it built it and ran a bunch of benchmarks, and then I got a breakpoint with this call stack:
'''

Benchmarks.exe!juce::LeakedObjectDetectorjuce::OggReader::LeakCounter::~LeakCounter() Line 104 C++
[External Code]
Benchmarks.exe!_execute_onexit_table::__l2::() Line 206 C++
Benchmarks.exe!__crt_seh_guarded_call::operator()<void (void),int (void) &,void (void)>(__acrt_lock_and_call::__l2::void (void) && setup, _execute_onexit_table::__l2::int (void) & action, __acrt_lock_and_call::__l2::void (void) && cleanup) Line 204 C++
Benchmarks.exe!__acrt_lock_and_call<int (void)>(const __acrt_lock_id lock_id, _execute_onexit_table::__l2::int (void) && action) Line 974 C++
Benchmarks.exe!_execute_onexit_table(_onexit_table_t * table) Line 231 C++
Benchmarks.exe!common_exit::__l2::() Line 221 C++
Benchmarks.exe!__crt_seh_guarded_call::operator()<void (void),void (void) &,void (void)>(__acrt_lock_and_call::__l2::void (void) && setup, common_exit::__l2::void (void) & action, __acrt_lock_and_call::__l2::void (void) && cleanup) Line 224 C++
Benchmarks.exe!__acrt_lock_and_call<void (void)>(const __acrt_lock_id lock_id, common_exit::__l2::void (void) && action) Line 974 C++
Benchmarks.exe!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 253 C++
Benchmarks.exe!exit(int return_code) Line 288 C++
[External Code]
'''
The source code at the breakpoint says
'''
if (numObjects.value > 0)
{
DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName());

/** If you hit this, then you've leaked one or more objects of the type specified by
    the 'OwnerClass' template parameter - the name should have been printed by the line above.

    If you're leaking, it's probably because you're using old-fashioned, non-RAII techniques for
    your object management. Tut, tut. Always, always use std::unique_ptrs, OwnedArrays,
    ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
*/
jassertfalse;

}
'''
The console has a lot of benchmark statements ending with
'''
LightweightSemaphore signal, Threads
Signal 10 (may not be waiting)
[seconds] 0.0350477 (min: 0, max: 4e-05, mean: 3.50477e-07, var: 1.42449e-13)
[cycles] 96088874 (min: 232, max: 105208, mean: 960, var: 1.11709e+06)

ERROR: Failed to publish!
'''

What is the expected behaviour?

I expected it not to call the breakpoint and to successfully publish the benchmarks (whatever that means).

Unit test to reproduce the error?

/*
    Copy this code in to your application, replacing the test cases in the runTest function.
    Then call runTest() from somewhere in your application.
*/
class TestClassName  : public juce::UnitTest
{
public:
    TestClassName()
        : juce::UnitTest ("TestClass", "tracktion_engine")
    {
    }

    void runTest() override
    {
        // Group tests in to sections with beginTest
        beginTest ("Test section");
        {
            expect (1 == 1);        // Test an expression for true
            expectEquals (1, 1);    // Test two values are equal
            expectNotEquals (1, 1); // Test two values are not equal: FAILS
        }
    }
};

// Creates an instance of the test so you can run it
static TestClassName testClassName;

// Call this from your applications
inline void runTest()
{
    juce::UnitTestRunner runner;
    runner.runTests ({ &testClassName });
}

Operating systems

Windows

What versions of the operating systems?

Windows 11

Architectures

x86_64

Stacktrace

'''
>	Benchmarks.exe!juce::LeakedObjectDetector<juce::OggReader>::LeakCounter::~LeakCounter() Line 104	C++
 	[External Code]	
 	Benchmarks.exe!_execute_onexit_table::__l2::<lambda>() Line 206	C++
 	Benchmarks.exe!__crt_seh_guarded_call<int>::operator()<void <lambda>(void),int <lambda>(void) &,void <lambda>(void)>(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, _execute_onexit_table::__l2::int <lambda>(void) & action, __acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Line 204	C++
 	Benchmarks.exe!__acrt_lock_and_call<int <lambda>(void)>(const __acrt_lock_id lock_id, _execute_onexit_table::__l2::int <lambda>(void) && action) Line 974	C++
 	Benchmarks.exe!_execute_onexit_table(_onexit_table_t * table) Line 231	C++
 	Benchmarks.exe!common_exit::__l2::<lambda>() Line 221	C++
 	Benchmarks.exe!__crt_seh_guarded_call<void>::operator()<void <lambda>(void),void <lambda>(void) &,void <lambda>(void)>(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, common_exit::__l2::void <lambda>(void) & action, __acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Line 224	C++
 	Benchmarks.exe!__acrt_lock_and_call<void <lambda>(void)>(const __acrt_lock_id lock_id, common_exit::__l2::void <lambda>(void) && action) Line 974	C++
 	Benchmarks.exe!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 253	C++
 	Benchmarks.exe!exit(int return_code) Line 288	C++
 	[External Code]	
'''

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

I have not tested against the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions