Skip to content

Python crashes on out of bounds array call to LUT2d.eval() #187

@scottstanie

Description

@scottstanie

Calling LUT2d.eval on a numpy array input with out of bounds elements crashes python. I think this is from the pybind11 bindings not catching the journal except when run within the openMP loop.

Reproducer:

import isce3, numpy as np, journal
x = np.linspace(0,5,10)
y = np.linspace(10,20,2)
z = np.vstack((np.linspace(100,200,10), np.linspace(100,200,10)))
lut2d = isce3.core.LUT2d(x, y, z)
print(lut2d.bounds_error)
# True

# Scalar inputs: exception is caught and it's okay
try:
    lut2d.eval(1.0, 11.0)
except RuntimeError as e:
    print(e)
# journal:
#  -- Out of bounds LUT2d evaluation at 1 11
#  --  - bounds are 10 20 0 5
# RuntimeError: isce.core.LUT2d: application error

# Mixed scalar/array: crashes Python
try:
    lut2d.eval(10.0, np.array([1.0,111.0]))
except RuntimeError as e:
    print(e)
# journal:
#  -- Out of bounds LUT2d evaluation at 10 111
#  --  - bounds are 10 20 0 5
# libc++abi: terminating due to uncaught exception of type pyre::journal::application_error
# <aborted>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions