Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Leaked objects detected in example source

Open
#254 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Reproduce by building examples/CMakeLists.txt (the Benchmarks target) in Visual Studio 2022 and running it under the debugger; the assertion fires in juce::LeakedObjectDetectorjuce::OggReader::LeakCounter::~LeakCounter at exit. Start by finding where the benchmark code creates or holds a juce::OggReader and whether that reference is released before shutdown, then trace the 'ERROR: Failed to publish!' path in the benchmark runner. Done means the run exits with no leak assertion and the benchmarks publish successfully.

Written by the indexing model from the issue text.

Description

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
Dominant language
C++
Stars
1.5k
Forks
222
Avg merge
15h 44m
Merged PRs (30d)
33

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Tracktion/tracktion_engine

All issues in Tracktion/tracktion_engine

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.