Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTilde test causes a bus error on MacOS M2 #191

Open
3 tasks
samcunliffe opened this issue Nov 18, 2022 · 3 comments
Open
3 tasks

DTilde test causes a bus error on MacOS M2 #191

samcunliffe opened this issue Nov 18, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@samcunliffe
Copy link
Member

Not caught in CI because pathological to MacOS on ARM64. Not reproducible on any other OS we've tried so far. Nor Mac M1 (thanks @t-young31).

The first SECTION macro in the DTilde test somehow causes a bus error (access to nonexistent memory). So far it seems that the call to mxDestroyArray is responsible.

Note
Links are at 3d0fe2c so that they're permanent. Likely this was introduced in earlier commits (#159, #162).

Low priority for now. Especially given that it's likely to be made obsolete by #70, but I'm making a ticket so I don't forget to investigate and check it goes with MATLAB.

Ideas

  • Update MATLAB (my Mac has 2022a and the CI runners are on b).
  • Try gdb on linux. lldb is not helpful.
  • Check matlab_array is non-empty somehow, intercept.

Links

Might relate to

@samcunliffe samcunliffe added the bug Something isn't working label Nov 18, 2022
@samcunliffe samcunliffe self-assigned this Nov 18, 2022
@samcunliffe
Copy link
Member Author

So adding debug output it’s the mxDestroyArray that causes it. Trail end of test_DTilde.cpp...

  // tear down
  SPDLOG_DEBUG("About to teardown");
  mxDestroyArray(test_input);
  SPDLOG_DEBUG("Called mxDestroyArray");
}

Results in:

➤ ./tdms_tests "DTilde" 
Filters: DTilde
Randomness seeded to: 1507720952
[2022-11-17 15:26:21.956] [debug] [test_DTilde.cpp:23] num_det_modes() == 0
[2022-11-17 15:26:21.957] [debug] [test_DTilde.cpp:25] !x.has_elements()
[2022-11-17 15:26:21.957] [debug] [test_DTilde.cpp:27] !y.has_elements()
[2022-11-17 15:26:21.957] [debug] [test_DTilde.cpp:30] REQUIRE macro is satisfied
[2022-11-17 15:26:21.957] [debug] [test_DTilde.cpp:96] About to teardown
zsh: bus error  ./tdms_tests "DTilde"

@willGraham01
Copy link
Collaborator

willGraham01 commented Nov 18, 2022

Check matlab_array is non-empty somehow, intercept.

mxDestroyArray is robust in the other test cases where it is called on an empty struct. What happens if on line 18 we explicitly initialise mxArray *matlab_input = nullptr? mxDestroyArray is supposedly robust in this case too, and matlab_input isn't actually set in the 1st test case.

As an asside: we need to be careful what we mean by "empty" since MATLAB distinguishes between "the struct with no fields" and a "0-by-x" dimensional struct. Both of which are seemingly empty.

@samcunliffe
Copy link
Member Author

"I know, in theory, how to fix it."

-- @willGraham01 5th June 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants