-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix access violation issue in libgpiod v1 driver #2311
Conversation
The handle is "owned" by the chip and is freed with that one. Freeing them in the wrong order causes an access violation
src/System.Device.Gpio/System/Device/Gpio/Drivers/Libgpiod/LibGpiodDriver.cs
Outdated
Show resolved
Hide resolved
src/System.Device.Gpio/Interop/Unix/libgpiod/V1/SafeLineHandle.cs
Outdated
Show resolved
Hide resolved
src/System.Device.Gpio/Interop/Unix/libgpiod/V1/SafeLineHandle.cs
Outdated
Show resolved
Hide resolved
src/System.Device.Gpio/Interop/Unix/libgpiod/V1/SafeLineHandle.cs
Outdated
Show resolved
Hide resolved
@@ -13,6 +13,12 @@ | |||
<Left>lib/netstandard2.0/System.Device.Gpio.dll</Left> | |||
<Right>lib/net6.0-windows10.0.17763/System.Device.Gpio.dll</Right> | |||
</Suppression> | |||
<Suppression> | |||
<DiagnosticId>CP0002</DiagnosticId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't expect this to show up as we should have the finalizer in both places. Can you please check why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no clue, but looks like a bug of the tool to me. We have added a finalizer, so why should there be a warning that it's now missing? I can't see why this would be a breaking change, anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified the generated IL. The finalize method is also present in the netstandard2.0 assembly.
/azp run dotnet.iot |
Azure Pipelines successfully started running 1 pipeline(s). |
@joperezr I unfortunately have no idea why we get that report about the missing finalizer. It is there in all places. |
Fixes #1849
After the cause is finally verified, this removes the SafeHandle base class from SafeLineHandle and changes it to a normal class. The line(s) are always disposed together with their chips, and thus do not need to be explicitly disposed. Lines (individual pins) must not be disposed after the chip is disposed.
This also adds various tests to make sure exceptions are thrown when attempting to use disposed drivers.
Microsoft Reviewers: Open in CodeFlow