Skip to content

BUG: np.memmap broken on Windows (maybe) #25665

Closed

Description

@larsoner

Sometime in the last week our Windows pip-pre job in MNE-Python started failing with:

mne\io\base.py:2376: in _allocate_data
    data = np.memmap(str(preload), mode="w+", dtype=dtype, shape=shape)
C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\site-packages\numpy\_core\memmap.py:233: in __new__
    f_ctx = open(
E   OSError: [Errno 22] Invalid argument: 'memmap.dat'

I restarted the job and got the same error. I find this a bit baffling and am not 100% sure this is a NumPy issue. I see #25409 touched memmap.py in the right time frame but I am not sure how __array_wrap__ could be a culprit here. Notably there is no failure on Linux pip-pre so somehow this is Windows-specific. EDIT: Also no failure on other Windows jobs so it seems likely to be NumPy 2.0.0.dev0-specific, too.

I will try to replicate locally on my Windows boot tomorrow but wanted to throw this out there in case anyone had ideas for immediate culprits. I thought maybe pytest could be an issue but their last stable 7.4.4 came out weeks ago and we've had green builds since then.

Activity

  1. added
    57 - Close?
    on Jan 23, 2024
  2. ngoldbaum commented on Jan 23, 2024

    @ngoldbaum
    Member

    This needs a bit more info to be actionable on our end

  3. larsoner commented on Jan 24, 2024

    @larsoner
    ContributorAuthor

    Looks like it has to do with reusing the same memmap files which is probably unsafe anyway. No idea why this happens only now but it seems like a bug at our end so I'll close, sorry for the noise!

  4. carbonox-infernox commented on Feb 28, 2025

    @carbonox-infernox

    I've also experienced this issue, but only while using mode='w+' on an existing memmap. It works fine with 'r+', but I think that, if nothing else, the documentation should reflect this. Currently, the row for w+ says:

    ‘w+’ | Create or overwrite existing file for reading and writing. If mode == 'w+' then shape must also be specified.

    This tells the user they can use 'w+' on an existing memmap.

  5. larsoner commented on Mar 3, 2025

    @larsoner
    ContributorAuthor

    @carbonox-infernox can you check to see if that's the case for plain NumPy arrays (i.e., without using MNE-Python at all)? If so then it's probably worth opening an issue in NumPy rather than MNE-Python to update their docs

  6. carbonox-infernox commented on Mar 19, 2025

    @carbonox-infernox

    @larsoner it must be an issue with regular NumPy, because I've never heard of MNE-Python before this moment. I suppose this is worth opening a separate issue without referring to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    57 - Close?

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions