isl-org / isl-org/Open3D

"Internal error: element size mismatch" while initializing tensor globally

Open
#5,754 0 comments 0 reactions 1 assignee Claimed by @yxlao 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

I wrote a simple test main.cpp and link to static Open3D library, then got the runtime error:

main.cpp:
```
#include

#include "open3d/core/Tensor.h"

open3d::core::Tensor points =
open3d::core::Tensor::Init(
{0.0, 0.0, 0.0},
open3d::core::Device("CPU:0"));

int main(int argc, char** argv)
{
return 0;
}
```

```
terminate called after throwing an instance of 'std::runtime_error'
what(): [Open3D Error] (void open3d::core::Tensor::AssertTemplateDtype() const [with T = double]) Open3D/build/install/include/open3d/core/Tensor.h:1187: Internal error: element size mismatch 0 != 8
```

I looked into the codes about tensor initalization,I think the reason is the Dtype::Float64, Dytpe::Float32 ... static member variables is not initialized while globally initializing Tensor.This runtime error would not occur while linking shared Open3D library.

### Steps to reproduce the bug

```python
*
```

### Error message

_No response_

### Expected behavior

_No response_

### Open3D, Python and System information

```markdown
- Operating system: Ubuntu 22.04
- Open3D version: 0.16.1
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc 11.3
```

### Additional information

_No response_

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.