Skip to content

Crash when processing SOFA files. Unclosed handle to native code. #410

@mmjamm

Description

@mmjamm

I ran into a problem when loading a bunch of directivities from Sofa files using MeasuredDirectivityFile(). Sometimes the script would crash silently without any error message.
The problem seems to stem from open_sofa_file (directivities/sofa.py). The handle opened with file_sofa = sofa.Database.open(path) is not closed. I guess in some circumstances it leads to a crash. The problem was fixed for me when I added file_sofa.close() to the last line of open_sofa_file() before the return statement.

Unfortunately I wasn't able to come up with a minimal example to reliably produce the crash. However, it seems to solve the problem for me and I think it's a safe modification to do in any case, so maybe it's worth adding to the source code?

Thanks for the superb library - I use it all the time!

Python version: 3.11.8
Pyroomacoustics version: 0.8.4
Venv dependencies: pyroomacoustics, numpy, python-sofa

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