Skip to content

File based aggregations not working in docker due to parameter typing error and also Windows kernel32 dependency #572

Description

@ansucu

When running docker image ghcr.io/pxtools/pxwebapi:2.3.0 (on either linux or windows host) an error is reported on startup:
ERROR PCAxis.Paxiom.GroupRegistry - Error loading the valueset file: /app/wwwroot/Aggregations/REGION-EN.vs, Error message: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination (String parameters and return types must be paired with LPStr, LPWStr, or LPTStr).

This is due to PCAxis.Core/Grouping/GroupRegistry.vb is using an immutable String in its declaration of GetPrivateProfileStringW:
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L17

ChatGPT: "In the Windows API, GetPrivateProfileStringW expects a mutable buffer (a pointer to a writable character array). But in .NET:

  • String is immutable
  • Passing it ByVal means it cannot be written into safely
  • On Windows, this sometimes “works by accident”
  • On Linux (or stricter runtimes), it fails with your exact marshalling error"

The solution would be to replace String with a StringBuffer for lpReturnedString, BUT...
...solving this would probably still not work in a Linux based docker image or on a Linux based host due to lacking support of kernel32 in such images/hosts.

ChatGPT: "Even after fixing this, you still have a platform problem:
kernel32.dll is Windows-only
This API does not exist on Linux
So in a Linux container, this will eventually fail..."

A better solution would be to either reimplement Inireader.Read (in PCAxis.Core a.k.a. Paxiom) not to use GetPrivateProfileStringW or to reimplement PxFileDataSource (in PxWebApi) not to use PCAxis.Paxiom.Grouping.GroupRegistry.
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L45

Grouping grouping = PCAxis.Paxiom.GroupRegistry.GetRegistry().GetGrouping(id);

My understanding is that PCAxis.Core (a.k.a. Paxiom) is not built when building the docker image but rather fetched from nuget repo.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions