PyCharm exit code -1073741819 (0xC0000005)

I have a function that uses jit (intersects_numba) which is called in another function (ray_intersection) that is used for ray tracing. If I obtain the objects that are arguments in the ray tracing function by simply creating them as outputs of other individual functions the script runs without any problems.
The problem occurs when I create those objects in a function that contains inside the smaller functions and I have all the objects as outputs of that said function.
After I do that, even though the objects are the same in the two cases, PyCharm is crashing in the intersects_numba function.

The code that I will share is the smallest reproducible one that I could create to show the error, since the full code is confidential.

from shapely.geometry import Polygon, Point, LineString
import numpy as np
from shapely.geos import lgeos
from numba import jit

GEOSContains_ctypes = lgeos._lgeos.GEOSContains_r
GEOSIntersects_r = lgeos._lgeos.GEOSIntersects_r
GEOS_HANDLE = lgeos.geos_handle


def get_all(polygon_a):
    polygon_shapely_a = np.array([Polygon(section_polygon) for section_polygon in polygon_a])
    polygon_geom = np.array([x._geom for x in polygon_shapely_a])

    return polygon_geom


@jit(nopython=True)
def intersects_numba(p_geom, array_geom, geos_handle):
    n = array_geom.shape[0]
    res = np.array([GEOSIntersects_r(geos_handle, p_geom, array_geom[i]) for i in range(n)])
    return res


def ray_intersection(ray_geom, polygon_geom):
    int_array = []
    for ii, line_string in enumerate(ray_geom):
        bool_array = intersects_numba(line_string, polygon_geom, GEOS_HANDLE)
        print(bool_array)
        int_array.append(bool_array)
    return int_array


def rt_arrays(ray, polygon_geom):
    linestring_ray = [LineString(linestring) for linestring in ray]
    geom_ray = np.array([x._geom for x in linestring_ray])
    int_arr = ray_intersection(geom_ray, polygon_geom)
    a = 2 + 2
    return a


polygon_list = [[[0.0, 0.0], [2500.0, 0.0], [2493.91, 174.391], [0.0, 0.0]],
                [[0.0, 0.0], [2493.91, 174.391], [2475.67, 347.933], [0.0, 0.0]],
                [[0.0, 0.0], [2475.67, 347.933], [2445.369, 519.779], [0.0, 0.0]],
                [[0.0, 0.0], [2445.369, 519.779], [2403.154, 689.093], [0.0, 0.0]],
                [[0.0, 0.0], [2403.154, 689.093], [2349.232, 855.05], [0.0, 0.0]],
                [[0.0, 0.0], [2349.232, 855.05], [2283.864, 1016.842], [0.0, 0.0]],
                [[0.0, 0.0], [2283.864, 1016.842], [2207.369, 1173.679], [0.0, 0.0]],
                [[0.0, 0.0], [2207.369, 1173.679], [2120.12, 1324.798], [0.0, 0.0]],
                [[0.0, 0.0], [2120.12, 1324.798], [2022.542, 1469.463], [0.0, 0.0]],
                [[0.0, 0.0], [2022.542, 1469.463], [1915.111, 1606.969], [0.0, 0.0]],
                [[0.0, 0.0], [1915.111, -1606.969], [2022.542, -1469.463], [0.0, 0.0]],
                [[0.0, 0.0], [2022.542, -1469.463], [2120.12, -1324.798], [0.0, 0.0]],
                [[0.0, 0.0], [2120.12, -1324.798], [2207.369, -1173.679], [0.0, 0.0]],
                [[0.0, 0.0], [2207.369, -1173.679], [2283.864, -1016.842], [0.0, 0.0]],
                [[0.0, 0.0], [2283.864, -1016.842], [2349.232, -855.05], [0.0, 0.0]],
                [[0.0, 0.0], [2349.232, -855.05], [2403.154, -689.093], [0.0, 0.0]],
                [[0.0, 0.0], [2403.154, -689.093], [2445.369, -519.779], [0.0, 0.0]],
                [[0.0, 0.0], [2445.369, -519.779], [2475.67, -347.933], [0.0, 0.0]],
                [[0.0, 0.0], [2475.67, -347.933], [2493.91, -174.391], [0.0, 0.0]],
                [[0.0, 0.0], [2493.91, -174.391], [2500.0, 0.0], [0.0, 0.0]]]
ray = [[[3.603, 16.128, 11.55], [2003.603, 16.128, 11.55]],
       [[3.603, 16.128, 11.55], [2003.2983900000002, 51.03281, 11.55]]]

polygon_geom_a = get_all(polygon_list)
a = rt_arrays(ray, polygon_geom_a)

Process finished with exit code -1073741819 (0xC0000005)

If I don’t use the get_all() function to create the polygon_geom object (In reality I create some other objects as well) the script is executed without a problem.

polygon_shapely_a = np.array([Polygon(section_polygon) for section_polygon in polygon_list])
polygon_geom_a = np.array([x._geom for x in polygon_shapely_a])

a = rt_arrays(ray, polygon_geom_a)

Process finished with exit code 0

I’d appreciate any help on this, this is the second time that I post the same issue, the first time I didn’t receive much feedback several months ago.

0cC0000005 is the exit code for an access violation in Windows - generally this occurs when a program access invalid / out of bounds memory. If you remove the jit decorators, does your program execute correctly?

(This is similar advice to the previous response you received - if the code doesn’t work without the jit decorator, then that needs to be resolved first before looking into issues using the jit decorator)