Skip to content

Commit

Permalink
add test for view of memmapped array after close
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Dec 7, 2023
1 parent f14f741 commit 1d74dce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions asdf/_tests/_regtests/test_1334.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np

import asdf


def test_memmap_view_access_after_close(tmp_path):
"""
Accessing a view of a memmap after the asdf file
is closed results in a segfault
https://github.com/asdf-format/asdf/issues/1334
"""

a = np.ones(10, dtype="uint8")
fn = tmp_path / "test.asdf"
asdf.AsdfFile({"a": a}).write_to(fn)

with asdf.open(fn, copy_arrays=False) as af:
v = af["a"][:5]

assert np.all(v == 1)

0 comments on commit 1d74dce

Please sign in to comment.