isl-org / isl-org/Open3D

Segmentation Fault when calling AddGeometry() about 65535 times.

Open
#4,992 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### Describe the issue

The segfault happens after calling `AddGeometry()` about 65535 times.
The type of geometry does not matter.
There may be a 16bit overflow error.

### Steps to reproduce the bug

```python
#include
#include
#include
#include

#include "open3d/Open3D.h"
#include "open3d/t/geometry/LineSet.h"

using namespace open3d;
using namespace open3d::visualization;

class MultipleWindowsApp {
public:
MultipleWindowsApp() { gui::Application::GetInstance().Initialize(); }

void Run() {
main_vis_ = std::make_shared(
"Open3D - Multi-Window Demo", 1024, 768);
main_vis_->ShowSettings(false);
main_vis_->ShowSkybox(false);

// camera setting
main_vis_->ResetCameraToDefault();
main_vis_->SetupCamera(60, {0, 0, 0}, {0, 0, -3}, {0.0f, -1.0f, 0.0f});

gui::Application::GetInstance().AddWindow(main_vis_);

std::thread read_thread([this]() { this->ReadThreadMain(); });
gui::Application::GetInstance().Run();
read_thread.join();
}

private:
void ReadThreadMain() {
// Init Geo
core::Tensor vertices(
std::vector{-10.0, -10.0, -10.0, 10.0, 10.0, 10.0},
{2, 3}, core::Float32);
core::Tensor edges{std::vector{0, 1}, {1, 2}, core::Int32};
any_geo_ = std::make_shared(vertices, edges);

//
for (int count = 0;; ++count) {
std::cout << count << "\n";
std::this_thread::sleep_for(std::chrono::milliseconds(5));

// If uncommnet below, the segfault not happens.
/*
if (count >= 65000) {
continue;
}
*/

// Update geometry (skip in this example)

// Rendering
gui::Application::GetInstance().PostToMainThread(
main_vis_.get(), [this]() {
std::lock_guard lock(render_lock_);
main_vis_->RemoveGeometry("geo_name");
main_vis_->AddGeometry("geo_name", any_geo_);
});
}
}

private:
std::shared_ptr main_vis_;

std::mutex render_lock_;
std::shared_ptr any_geo_;
};

int main() {
MultipleWindowsApp().Run();
return 0;
}
```

### Error message

Segmentation fault (core dumped)

### Expected behavior

_No response_

### Open3D, Python and System information

```markdown
- Operating system: Ubuntu 20.04
- Open3D version: 0.15.1
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: Use pre built open3d-devel-linux-x86_64-cxx11-abi-0.15.1
- Compiler version (if built from source): gcc 9.4
```

### Additional information

#4881 looks related issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.