gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Rendering engines are not unloaded or cleaned up when `Server` is destroyed

Open azeey opened this issue 2 years ago • 0 comments

Environment

  • OS Version: Ubuntu 20.04
  • Source or binary build? ign-gazebo5

Description

  • Expected behavior: The rendering engine to be unloaded when Server (or more specifically, RenderUtil) is destroyed.
  • Actual behavior: The rendering engine and all the scenes within it remain intact after Server is destroyed. Loading the same world in two tests in the same file causes the test to segfault. @marcoag ran into this while working on #1331.

Steps to reproduce

Add these two tests to test/integration/depth_camera.cc (or any integration test file) and run with --gtest_filter="*Cleanup*"


TEST(RenderingCleanup, Cleanup1)
{
  // Start server
  ServerConfig serverConfig;
  const auto sdfFile = std::string(PROJECT_SOURCE_PATH) +
    "/test/worlds/depth_camera_sensor.sdf";
  serverConfig.SetSdfFile(sdfFile);

  Server server(serverConfig);

  server.Run(true, 10, false);
}

TEST(RenderingCleanup, Cleanup2)
{
  // Start server
  ServerConfig serverConfig;
  const auto sdfFile = std::string(PROJECT_SOURCE_PATH) +
    "/test/worlds/depth_camera_sensor.sdf";
  serverConfig.SetSdfFile(sdfFile);

  Server server(serverConfig);

  server.Run(true, 10, false);
}

Output

❯ bin/INTEGRATION_depth_camera --gtest_filter="*Cleanup*"
Running main() from /home/addisu/ws/edifice/src/ign-gazebo/test/gtest/src/gtest_main.cc
Note: Google Test filter = *Cleanup*
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from RenderingCleanup
[ RUN      ] RenderingCleanup.Cleanup1
[       OK ] RenderingCleanup.Cleanup1 (1280 ms)
[ RUN      ] RenderingCleanup.Cleanup2
[Err] [SceneManager.cc:179] Visual: [ground_plane] already exists
[Err] [SceneManager.cc:179] Visual: [box] already exists
[Err] [SceneManager.cc:179] Visual: [depth_camera] already exists
[Err] [BaseStorage.hh:927] Another item already exists with name: sun
[1]    1357836 segmentation fault  bin/INTEGRATION_depth_camera --gtest_filter="*Cleanup*"

azeey avatar Mar 24 '22 22:03 azeey