upkie / vulp

Robot/simulation switch for the mjbots stack
Apache License 2.0
61 stars 4 forks source link

[macOS] allocate_file fails with ENXIO (errno 6) #27

Closed ubgk closed 1 year ago

ubgk commented 1 year ago

SetUp() in SpineTest.cpp (#15) fails due to ENXIO (errno 6) thrown by AgentInterface.cpp:allocate_file, which means (according to the man entry):

      6 ENXIO No such device or address.  Input or output on a special file
             referred to a device that did not exist, or made a request beyond
             the limits of the device.  This error may also occur when, for
             example, a tape drive is not online or no disk pack is loaded on
             a drive.

As AgentInterface constructor checks for errors after shm_open, what do you think could cause the write to fail? @stephane-caron

You can see the logs here: error.log

ubgk commented 1 year ago

I know it's a hard problem to tell without being able to reproduce on your system. I'll try to see if I can write a short contrived example using shm_open and write to reproduce the error elsewhere.

stephane-caron commented 1 year ago

We can probably fix the first error from the log easily:

[2023-05-22 15:36:48.084] [error] Cannot open shared memory "tester": file already exists. Is the spine already running? Did it not exit properly? If not, run ``bazel run @vulp//tools/shm:clean -- tester``

This may occur because the tests run in separate threads, but the fixture opens a file named "tester" in shared memory:

  void SetUp() override {
    agent_interface_ = std::make_unique<AgentInterface>("tester", 1024);
  }

We can work around that with a random_string() like in the other test fixtures.

ubgk commented 1 year ago

Done, that error is fixed by https://github.com/tasts-robots/vulp/pull/15/commits/fe5f59981f6c64282e54d9386e9c20307f131ed0

ubgk commented 1 year ago

Python tests are also fixed by https://github.com/tasts-robots/vulp/pull/15/commits/f7ff0ebbeb47340e44a1f0559cf009a69c93c4ea which closes the memory map and unlinks the shared memory after each test to prevent setUp from trying to create a new shared memory file with the same name before each test. Does that look OK to you? @stephane-caron

If it makes sense, it should also be possible to make sure setUp runs only once for the entire class, but I haven't looked at it.

stephane-caron commented 1 year ago

LGTM. You will need to clang-format some files like:

ERROR: actuation/Interface.cpp needs clang-format

so that we see if the tests pass. If all tests pass then it's good to go :ok_hand:

stephane-caron commented 1 year ago

Closing this issue as fixed by https://github.com/tasts-robots/vulp/pull/30 (we forgot to mark it in the PR).

Feel free to open another issue for the next macOS error.