Skip to content

ReadAsync() ThrowIfStatusNotOk(readTask.Task.Result) throws ErrorNotImplemented on Alpine Linux #447

@OtavioDePaula

Description

@OtavioDePaula

Hi, I'm using libplctag in a .NET 6 application. I'm calling the ReadAsync() method from your C# wrapper.

When running on Alpine Linux, and I can't handle this using a basic try/catch, it's crashing my entire app, it always throws the following exception:

try
{
    lock (item)
    {
        var tagRead = _tagsRead[item];
        tagRead.ReadAsync();
    }
}
catch (Exception e)
{
}
Unhandled exception. System.AggregateException: One or more errors occurred. (ErrorNotImplemented)
 ---> libplctag.LibPlcTagException: ErrorNotImplemented
   at libplctag.Tag.Qo2yXV0rXkT(Nullable`1  )
   at libplctag.Tag.Abort()
   at libplctag.Tag.<>c__DisplayClass134_0.StwyBqT7PRQ()
   at System.Threading.CancellationToken.<>c.<Register>b__12_0(Object obj)
   at System.Threading.CancellationTokenSource.Invoke(Delegate d, Object state, CancellationTokenSource source)
   at System.Threading.CancellationTokenSource.CallbackNode.<>c.<ExecuteCallback>b__9_0(Object s)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.CancellationTokenSource.CallbackNode.ExecuteCallback()
   at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException)
   --- End of inner exception stack trace ---
   at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException)
   at System.Threading.CancellationTokenSource.NotifyCancellation(Boolean throwOnFirstException)
   at System.Threading.CancellationTokenSource.TimerCallback(Object state)
   at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

You can see part of the full dump in the attached log. It seems to happen deep inside the Abort() method and callback registration.

Also, I noticed another issue: when I publish the app using dotnet publish -r linux-musl-x64, the libplctag.so is not correctly built for musl (Alpine). The published file is targeting glibc (x64) instead. Because of this, I need to clone the libplctag repo and build the .so file manually to make it work on Alpine.
This problem here: #341

It used to work directly with publish, but now I always have to build the native lib myself.

DUMP01.txt

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