Skip to content

Python crash on access to the result of numpy.fromfile #17819

@takeshi87

Description

@takeshi87

Python crashes on access to array read from a file, in case count is above file size (and probably some other restrictions - not all combinations of file size, count and offset result in crash. The one below was verified to crash on two different computers).
Provided dtype also seems to be an important factor.

Reproducing code example:

import numpy as np
np.zeros(511).tofile('testfile')
print(np.fromfile('testfile', dtype=np.dtype((np.int32, 2)), count = 100000))

Error message:

Python crash due to memory access violation

NumPy/Python version information:

1.17.4 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions