BUG: Fix default value crash - #179
Conversation
Add CPU parameters postprocessing in Server initialization.
Added tests to verify default and explicit thread counts in Llama server.
There was a problem hiding this comment.
Code Review
This pull request integrates CPU parameter post-processing during the initialization of the Server class in Cython, mirroring the CLI's behavior to resolve negative thread counts (such as -1 for auto) to the actual number of math cores. This prevents potential crashes when the C++ server creates its threadpools. Additionally, unit tests have been added to verify both default and explicit thread count behaviors. Feedback suggests declaring the common_params parameter as not None in __cinit__ to avoid potential null pointer dereferences or segmentation faults.
| @@ -3111,6 +3111,15 @@ cdef class Server: | |||
| cdef shared_ptr[CServer] svr | |||
|
|
|||
| def __cinit__(self, CommonParams common_params): | |||
There was a problem hiding this comment.
To prevent potential null pointer dereferences or segmentation faults when None is passed as common_params, declare the parameter with not None. In Cython, accessing attributes (like common_params.p) on a None object can lead to undefined behavior or crashes if nonecheck is disabled.
def __cinit__(self, CommonParams common_params not None):
No description provided.