Skip to content

System.BadImageFormatException using tasks in F# 6.0 #12189

@Lanayx

Description

@Lanayx

Please provide a succinct description of the issue.

Repro steps

The following test fails in Pulsar.Client repo, fsharpsix branch when built with new msbuild
(Microsoft (R) Build Engine version 17.0.0-preview-21460-01+8f208e609 for .NET)
in runtime (link to failed github action)

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)
   at <StartupCode$Pulsar-Client>.$ConsumerImpl.clo@122-84.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Pulsar.Client.Api.ConsumerImpl`1.wrapPostAndReply[U](Task`1 mbAsyncReply) in D:\Work\Pulsar.Client\src\Pulsar.Client\Internal\ConsumerImpl.fs:line 122
   at Pulsar.Client.Api.ConsumerImpl`1.Pulsar.Client.Api.IConsumer<'T>.SeekAsync(MessageId messageId) in D:\Work\Pulsar.Client\src\Pulsar.Client\Internal\ConsumerImpl.fs:line 1569
   at Pulsar.Client.Internal.ReaderImpl`1.Pulsar.Client.Api.IReader<'T>.SeekAsync(MessageId msgId) in D:\Work\Pulsar.Client\src\Pulsar.Client\Internal\ReaderImpl.fs:line 79
   at Pulsar.Client.IntegrationTests.Reader.basicReaderCheck@35-1.MoveNext() in D:\Work\Pulsar.Client\tests\IntegrationTests\Reader.fs:line 61

which is failing at the start of the following function

    let wrapPostAndReply (mbAsyncReply: Task<ResultOrException<'A>>) =
        task {
            match! mbAsyncReply with
            | Ok msg ->
                return msg
            | Error ex ->
                return reraize ex
        }

When building the solution with old compiler
( Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework )
I'm getting build errors, they can be observed in github actions
image

I suspect this might be the issue

Unfortunately I couldn't reproduce it on a simpler case for now, maybe later or someone else will help

Steps to run integration tests:

  1. Start Pulsar cluster (assuming Docker desktop is installed)
git clone https://github.com/fsharplang-ru/pulsar-client-dotnet
git checkout fsharpsix
cd tests\compose\standalone
docker-compose up

Wait about 2 minutes until the messages flow in console stops (you'll see the message 'Transaction coordinator metadata setup success')

  1. Run integration tests
dotnet build
cd tests\IntegrationTests
dotnet run

Expected behavior

The test passes successully when build with both old and new compiler, i.e. it should just work like TaskBuilder.fs worked. (develop branch in Pulsar.Client repo)

Actual behavior

When build with new compiler tests fail in runtime
When build with old compiler code doesn't compile

Known workarounds

Not to upgrade to 6.0

Related information

  • Windows 10
  • Library is built as .NET Standard 2.0
  • Jetbrains Rider

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