Skip to content

Crash at assertion on message length in dispatch.c #1452

@hakanai

Description

@hakanai

We discovered an issue where on upgrading our build machines to macOS 12, tests started to crash with an assertion failure in JNA's dispatch.c - presumably the error from dlerror() is now longer than JNA's permitted maximum of 1024.

On investigation, it seems the error only gets triggered if loading the library fails - the test in particular which triggered this is possible to skip for macOS, but I don't yet know whether we'll also see the same thing in production.

One fix would be to stop asserting this - another would be to figure out what the actual maximum error message length is and raise the limit to accommodate it. I already checked the docs for dlerror() and it doesn't seem to say.

On further investigation, the error message from dlerror() includes full diagnostics for which paths it tried to load - so the longer your library search path is, the more likely you will hit the limit and crash.

Steps to reproduce

  • Be on macOS 12+
  • Have a relatively long DYLD_LIBRARY_PATH (we had 5 entries in it - issue didn't happen if I reduced it to 1 entry)
  • Try to load a library which does not exist

What happens

Assertion failed: (count <= len && "snprintf() output has been truncated"), function LOAD_ERROR, file dispatch.c, line 74.

Followed by crashing with exit code 134.

Versions in use

  • JNA: 5.10.0
  • JVM: 11.0.12
  • OS: macOS 12
  • Architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions