allwpilib icon indicating copy to clipboard operation
allwpilib copied to clipboard

[wpilibc] Fixed memory leak during initialization

Open thenetworkgrinch opened this issue 3 years ago • 10 comments

ADIS16448_IMU.cpp allocated memory for DigitalOutput and DigitalInput objects without properly releasing or saving them.

thenetworkgrinch avatar Apr 17 '22 17:04 thenetworkgrinch

Idk if deleting the DigitalInput afterwards actually works because that may unconfigure the pin.

calcmogul avatar Apr 17 '22 17:04 calcmogul

Should I just make it identical by adding m_status_led and m_reset_in to the ADIS classes?

thenetworkgrinch avatar Apr 17 '22 17:04 thenetworkgrinch

The destruction operator overload and close override are identical

thenetworkgrinch avatar Apr 17 '22 17:04 thenetworkgrinch

Sure, but does this PR actually work on real hardware?

calcmogul avatar Apr 17 '22 17:04 calcmogul

Not tested yet

thenetworkgrinch avatar Apr 17 '22 17:04 thenetworkgrinch

In reference to https://github.com/wpilibsuite/allwpilib/issues/3985#issue-1122270795

thenetworkgrinch avatar Apr 17 '22 17:04 thenetworkgrinch

/azp run

calcmogul avatar Apr 24 '22 22:04 calcmogul

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 24 '22 22:04 azure-pipelines[bot]

Like I said before, this PR needs to be tested on real hardware since it's messing with hardware configuration. I don't have access to said hardware.

calcmogul avatar May 13 '22 23:05 calcmogul

If there's some minimal code to test this, I might be able to run it on hardware.

Starlight220 avatar Jun 14 '22 08:06 Starlight220

This doesn't really need a hardware test, it's only modifying destructor behavior to clean up resources. The deletions do need to be moved to Close() for consistency with the other cleanup code.

PeterJohnson avatar Aug 31 '22 16:08 PeterJohnson

Just moved them to Close() for consistency.

thenetworkgrinch avatar Sep 01 '22 20:09 thenetworkgrinch

/wpiformat

calcmogul avatar Sep 01 '22 21:09 calcmogul

To retrigger the builds, please rebase. Thanks and sorry for the inconvenience (we've since fixed the action automation so this doesn't happen in the future).

PeterJohnson avatar Sep 02 '22 16:09 PeterJohnson