Skip to content

ModuleBuilder.DefineType is not thread-safe #161

@melimion

Description

@melimion

ModuleBuilder.DefineType is not thread-safe, it causes errors in Android environment in case of concurrent execution.
https://msdn.microsoft.com/en-us/library/system.reflection.emit.modulebuilder%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396#Anchor_9

It is wrapped in lock in Microsoft implementation: https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/reflection/emit/modulebuilder.cs#L1141

But it isn't in Mono implementation:
https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs#L274

To fix wrap usage with lock in DynamicObjectTypeBuilder BuildType method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions