Incorrect winmode in load_shared_library

Open Beginner friendly
#1,993 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend, tooling

Research direction

Look at the load_shared_library method in the codebase, likely in a file handling library loading. The issue points to a line setting winmode to ctypes.RTLD_GLOBAL. Find where this method is defined, understand the ctypes documentation for winmode, and change the value to None. Test by ensuring the library loads dependencies correctly on Windows.

Written by the indexing model from the issue text.

Description

In the method load_shared_library the winmode specification is incorrect.

The actual code is:

cdll_args["winmode"] = ctypes.RTLD_GLOBAL

ctypes.RTLD_GLOBAL is not a value for winmode but only for mode argument.
The documentation is correct at https://docs.python.org/3/library/ctypes.html but confusing.

The winmode parameter is used on Windows to specify how the library is loaded (since mode is ignored). It takes any value that is valid for the Win32 API LoadLibraryEx flags parameter

The correct value should be None to use the default dll searching by ctype

Specifiy RTLD_GLOBAL (that is 0) will make the LoadLibraryEx search the dlls as the normal LoadLibrary function, behaving incorrectly and eventually not finding the dependencies.

Dominant language
Python
Stars
10.6k
Forks
1.5k
Avg merge
23m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from abetlen/llama-cpp-python

All issues in abetlen/llama-cpp-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.