VSoftTechnologies/DUnitX

WillRaiseAttribute memory leak

Opened this issue · 6 comments

[Test, WillRaise(EJobNotAllowed)]
procedure TestError;

Test passes, but when app closes FastMM4 reports memory leak.
If using
Assert.WillRaise(TestError, EJobNotAllowed)
everthing is fine, no memory leaks.

Also seeing this - below is an example FastMM stack trace for one of the leaked blocks:

A memory block has been leaked. The size is: 52

This block was allocated by thread 0x3558, and the stack trace (return addresses) at the time was:
409C66 [System][@GetMem$qqri]
40C3FF [System][TObject.NewInstance$qqrv]
40CC12 [System][@ClassCreate$qqrpvzc]
5D640F [DUnitX.WeakReference][Generics.Collections.%TList__1$pv%.$bctr$qqrv]
409C32 [System][AllocMem$qqri]
40CEF2 [System][TMonitor.Create$qqrv]
5D5F09 [DUnitX.WeakReference][Weakreference.TWeakReferencedObject.AddWeakRef$qqrpv]
4128A8 [System][@IntfCast$qqrr44System.%DelphiInterface$17System.IInterface%x44System.%DelphiInterface$17System.IInterface%rx5_GUID]
40C893 [System][@IsClass$qqrxp14System.TObjectp17System.TMetaClass]
40C8BE [System][@AsClass$qqrxp14System.TObjectp17System.TMetaClass]
5F52FE [DUnitX.TestResult][Weakreference.%TWeakReference__1$57System.%DelphiInterface$30Dunitx.Testframework.ITestInfo%%.$bctr$qqrx57System.%DelphiInterface$30Dunitx.Testframework.ITestInfo%]
40C408 [System][TObject.NewInstance$qqrv]
5F4986 [DUnitX.TestResult][Testresult.TDUnitXTestResult.$bctr$qqrx57System.%DelphiInterface$30Dunitx.Testframework.ITestInfo%x36Dunitx.Testframework.TTestResultTypex20System.UnicodeStringx56System.%DynamicArray$32Dunitx.Testframework.TLogMessage%]
607010 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteSuccessfulResult$qqrx72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix53System.%DelphiInterface$26Dunitx.Extensibility.ITest%x20System.UnicodeStringx56System.JzUhU2QduHE
6072DC [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteTest$qqrx72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix53System.%DelphiInterface$26Dunitx.Extensibility.ITest%x66System.%DelphiInterface$39Dunitx.Testframe80bE8DBKc5m
607870 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteTestSetupMethod$qqrx72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix60System.%DelphiInterface$33Dunitx.Extensibility.ITestFixture%x53System.%DelphiInterface$7n7pIA56nA1
607513 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteTests$qqrx72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix60System.%DelphiInterface$33Dunitx.Extensibility.ITestFixture%x62System.%DelphiInterface$35Dunitx.TSfr3igC6GY1
606BE8 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteFixtures$qqrx62System.%DelphiInterface$35Dunitx.Testframework.IFixtureResult%x72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix64System.%DelphiInterface$37DunwCT0JAspu9l
606C15 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteFixtures$qqrx62System.%DelphiInterface$35Dunitx.Testframework.IFixtureResult%x72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix64System.%DelphiInterface$37DunwCT0JAspu9l
606C15 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteFixtures$qqrx62System.%DelphiInterface$35Dunitx.Testframework.IFixtureResult%x72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix64System.%DelphiInterface$37DunwCT0JAspu9l
606C15 [DUnitX.TestRunner][Testrunner.TDUnitXTestRunner.ExecuteFixtures$qqrx62System.%DelphiInterface$35Dunitx.Testframework.IFixtureResult%x72System.%DelphiInterface$45Dunitx.Internalinterfaces.ITestExecuteContext%xuix64System.%DelphiInterface$37DunwCT0JAspu9l

The block is currently used for an object of class: TList<System.Pointer>

Is this still a problem with the current source?

Yes, it is.

Please submit a PR with a unit test that shows this and I'll take a stab at it.

How can I create a branch in order to put the unit test and create a PR?
I tried and failed because have no access to do it.

Fork the repository in Github, clone the fork to your machine.
In your clone, create a branch
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
add the unit test and then push your branch (git push), go to your fork in github and you will see it prompting you to create a pull request.

https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request