8000 BUG: The "default floatingpoint error setting" logic can misfire, especially with threads · Issue #19006 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
BUG: The "default floatingpoint error setting" logic can misfire, especially with threads  #19006
Closed
@seberg

Description

@seberg

The lines at

if ((errmask != UFUNC_ERR_DEFAULT) || (bufsize != NPY_BUFSIZE)
|| (PyTuple_GET_ITEM(errobj, 1) != Py_None)) {
PyUFunc_NUM_NODEFAULTS += 1;
}
else if (PyUFunc_NUM_NODEFAULTS > 0) {
PyUFunc_NUM_NODEFAULTS -= 1;
}

are wrong. Before getting that error, the previous error may already have been default (or may not have been set at all). In that case, a "num-defaults" is decremented. This logic really needs to check the previous state more than the current, I think.

This can be triggered using only one thread, even with np.errstate:

arr = np.arange(3)


with np.errstate(all="raise"):
    with np.errstate("all="ignore"):
        pass

# gives the correct value, but uses the lookup (using threads, the opposite will be possible
# -- although not super likely -- using the "defaults" even though the defaults are not set.
np.add(arr, arr)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0