Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Don't crash if pinvoke has a function pointer - #1350

Merged
MichalStrehovsky merged 1 commit into
masterfrom
MichalStrehovsky-patch-1
Jul 13, 2020
Merged

MichalStrehovsky merged 1 commit into
masterfrom
MichalStrehovsky-patch-1

Conversation

@MichalStrehovsky

@MichalStrehovsky MichalStrehovsky commented Jul 13, 2020 •

Copy link
Copy Markdown
Member

Linker tries to mark all instance fields on types referenced from p/invoke signatures but fails for function pointers because of a Cecil footgun (TypeSpecification has an ElementType property that is the actual element type for pointers/byrefs/arrays, is the generic definition for generic types, and null for pointer types).

(We shouldn't actually need to mark the instance fields in the first place because these need to have a non-Auto layout but I digress. If something actually needs that behavior, this is still buggy because it needs to happen recursively to actually work in interop, but CoreCLR would block Auto classes/structs right away.)

Fixes #1345.

Linker tries to mark all instance fields on types referenced from p/invoke signatures but fails for function pointers because of a Cecil footgun (`TypeSpecification` has an `ElementType` property that is the actual element type for pointers/byrefs/arrays, is the generic definition for generic types, and `null` for pointer types).

(We shouldn't actually need to mark the instance fields in the first place because these need to have a non-Auto layout but I digress.)
@MichalStrehovsky
MichalStrehovsky merged commit eaacef2 into master Jul 13, 2020
@MichalStrehovsky
MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch July 13, 2020 11:31
tkapin pushed a commit to tkapin/runtime that referenced this pull request Jan 31, 2023
Linker tries to mark all instance fields on types referenced from p/invoke signatures but fails for function pointers because of a Cecil footgun (`TypeSpecification` has an `ElementType` property that is the actual element type for pointers/byrefs/arrays, is the generic definition for generic types, and `null` for pointer types).

(We shouldn't actually need to mark the instance fields in the first place because these need to have a non-Auto layout but I digress.)

Commit migrated from dotnet/linker@eaacef2
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.

Linker crashes on interop method with function pointers

2 participants