Skip to content
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

Merged
merged 10 commits into from
Jun 13, 2024

Conversation

pgrawehr
Copy link
Contributor

@pgrawehr pgrawehr commented May 5, 2024

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

@@ -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>
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@joperezr joperezr added this to the v3.2.0 milestone May 23, 2024
@joperezr
Copy link
Member

/azp run dotnet.iot

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pgrawehr
Copy link
Contributor Author

pgrawehr commented Jun 8, 2024

@joperezr I unfortunately have no idea why we get that report about the missing finalizer. It is there in all places.

@krwq krwq merged commit 7f32e2d into dotnet:main Jun 13, 2024
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault in finalization with LibGpiodDriver
3 participants