Skip to content

ffi.lib.LLVMPY_TryAllocateExecutableMemory() not triggering OSError. #1397

Description

@perdigao1

errno = ffi.lib.LLVMPY_TryAllocateExecutableMemory()

I am experiencing "Windows fatal exception: access violation" at "from numba import jit" line. The problem traces to this call ffi.lib.LLVMPY_TryAllocateExecutableMemory()

I have noticed that this error does not occur in different systems and, the error is probably triggered by a security OS block when it allocates RW memory and tries to flip to RX (executable) memory, as required by the JIT. Although there's probably no workaround, the code is supposed raise a OSError. However it never raises this error because the value of errno is set to zero by the function despite the error.

def check_jit_execution():
    """
    Check the system allows execution of in-memory JITted functions.
    An exception is raised otherwise.
    """
    errno = ffi.lib.LLVMPY_TryAllocateExecutableMemory()  # <== "Windows fatal exception" here, but errno is set to zero
    if errno != 0:
        raise OSError(errno,
                      "cannot allocate executable memory. "
                      "This may be due to security restrictions on your "
                      "system, such as SELinux or similar mechanisms."

Metadata

Metadata

Assignees

No one assigned

    Labels

    needtriageNeeds to be triaged further

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions