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

Fix segfault (lambda reference capture) of VisualizerWithCustomAnimation::Play #6804

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

nicolaloi
Copy link
Contributor

@nicolaloi nicolaloi commented May 25, 2024

Type

Motivation and Context

Fixing segmentation fault when running an animation (clicking CTRL+P) with draw_geometries_with_custom_animation.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

The segmentation fault in VisualizerWithCustomAnimation.cpp is caused by line 124: ++progress_bar;, with progress_bar being a utility::ProgressBar instance captured by reference by a lambda expression. It seems like a dangling reference. Converting progress_bar to a shared pointer fixes the segmentation fault.

Testing

Before the change, this MRE will raise a segmentation fault after clicking CTRL+N and CTRL+P; after the change, it will run correctly:

# Instructions: When the window opens, 
# click CTRL+N to automatically add 360 spin keyframes, 
# then CTRL+P to play the animation

import open3d as o3d

with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Debug):
    sample_data = o3d.data.DemoCustomVisualization()
    pcd = o3d.io.read_point_cloud(sample_data.point_cloud_path)

    o3d.visualization.draw_geometries_with_custom_animation([pcd])

@ssheorey ssheorey self-requested a review June 14, 2024 17:58
Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nicolaloi looks good. I added a commit to fix the CI failure with clang.

@ssheorey ssheorey merged commit f7161f4 into isl-org:main Jun 14, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault when play animation with o3d.visualization.draw_geometries_with_custom_animation
2 participants