Segmentation fault with jitclass Linked List

Hi!

I have been using the numba example on how to implement a linked list using a jitclass from here. I then added a function to convert from a numpy array to this list. For an array length of up to ~100,000 elements, the function works as expected, but if there are more than ~1,000,000 I get a segmentation fault when trying to access the first node.

The following function converts the array:

@njit
def convert_array_to_list(arr: np.ndarray):
    start_node = make_linked_node(arr[0])
    previous_node = start_node
    for i in range(1, len(arr)):
        previous_node = previous_node.prepend(arr[i])
    print(start_node)  # Here start node does not seem to be available
    return start_node

You could find a whole working example here.

I am running:

  • numba: 0.53.0
  • python: 3.7
  • MacOS: 10.14

Has anyone got a suggestion on why this could happen?

Hi @beani_wonder,

I suspect the cause of the SIGSEGV is a stack overflow, the example Numba jitclass segmentation fault ยท GitHub should run if you increase the stack size. You can do this with ulimit on unix-like systems.

Hope this helps?

Hi @stuartarchibald!

Thank you for the quick reply :-). First, apparently there is no way to raise the RLIMIT_STACK on MacOS due to a bug in Python (more on that in the Python bug tracker). But I ran the same tests on my Linux machine and added:

import resource
resource.setrlimit(resource.RLIMIT_STACK, (10_000_000, resource.RLIM_INFINITY))

at the top of my module, but this still gives me a segmentation fault?

@stuartarchibald Update, I got it working setting it before starting Python using ulimit -s 65000 on my Linux machine. Thanks a lot!

@beani_wonder no problem, glad you got it working :slight_smile: