[custom] How can I debug crashes in which deallocation of point clouds uses the wrong point type?

未关闭
#5,579 12 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
cpp

调研方向

以 AddressSanitizer 回溯为切入点,沿着 filter.h 和 point_cloud.h 跟进到 Eigen's Memory.h。将 PointXYZRGB 的释放路径与跟踪信息中显示的 PointXYZL 分配进行比较,包括 PCL_NO_PRECOMPILE 和所列构建标志的影响。完成的标准是确定一个可复现的原因,或为不匹配的点类型提供精确的调试指导。

由索引模型根据 Issue 内容生成。

描述

status: triage

I often have this issue – not reproducible minimally – that my PCL client code crashes with some sort of

pointer being freed was not allocated

message, that usually goes away when I #define PCL_NO_PRECOMPILE at the top of my offending source file. With clang's address sanitizer, I get interesting reports that seem to indicate that a point cloud created as one point type gets deallocated as a different one. For instance check out this backtrace:

==47757==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x0001270383f8 at pc 0x000100af7ad8 bp 0x00016f4acd30 sp 0x00016f4acd28
READ of size 8 at 0x0001270383f8 thread T0
    #0 0x100af7ad4 in Eigen::internal::handmade_aligned_free(void*) Memory.h:118
    #1 0x100af7a5c in Eigen::internal::aligned_free(void*) Memory.h:206
    #2 0x100e01ce8 in Eigen::aligned_allocator<pcl::PointXYZRGB>::deallocate(pcl::PointXYZRGB*, unsigned long) Memory.h:897
    #3 0x100e01b18 in std::__1::allocator_traits<Eigen::aligned_allocator<pcl::PointXYZRGB> >::deallocate(Eigen::aligned_allocator<pcl::PointXYZRGB>&, pcl::PointXYZRGB*, unsigned long)
allocator_traits.h:282
    #4 0x100e01804 in std::__1::__vector_base<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB> >::~__vector_base() vector:488
    #5 0x100e015c4 in std::__1::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB> >::~vector() vector:579
    #6 0x100e00f70 in std::__1::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB> >::~vector() vector:574
    #7 0x100e03294 in pcl::PointCloud<pcl::PointXYZRGB>::~PointCloud() point_cloud.h:172
    #8 0x100e03254 in pcl::PointCloud<pcl::PointXYZRGB>::~PointCloud() point_cloud.h:172
    #9 0x103cc6510 in pcl::Filter<pcl::PointXYZRGB>::filter(pcl::PointCloud<pcl::PointXYZRGB>&) filter.h:134
    #10 0x103c6e6a8 in myfunction(mydata*) myfile.cpp:122
…
    #14 0x114051088 in start+0x204 (dyld:arm64e+0x5088)

0x0001270383f8 is located 8 bytes to the left of 52256-byte region [0x000127038400,0x000127045020)
allocated by thread T0 here:
    #0 0x120656ca8 in wrap_malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3eca8)
    #1 0x1169024d4 in std::__1::__split_buffer<pcl::PointXYZL, Eigen::aligned_allocator<pcl::PointXYZL>&>::__split_buffer(unsigned long, unsigned long, Eigen::aligned_allocator<pcl::Poi
ntXYZL>&)+0x30 (libpcl_filters.1.13.0.99.dylib:arm64+0x464d4)
    #2 0x1169037e4 in std::__1::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB> >::__append(unsigned long)+0x68 (libpcl_filters.1.13.0.99.dylib:arm64+0x477e4)
    #3 0x116a89e94 in pcl::VoxelGrid<pcl::PointXYZRGB>::applyFilter(pcl::PointCloud<pcl::PointXYZRGB>&)+0xaf0 (libpcl_filters.1.13.0.99.dylib:arm64+0x1cde94)
    #4 0x103cc63a4 in pcl::Filter<pcl::PointXYZRGB>::filter(pcl::PointCloud<pcl::PointXYZRGB>&) filter.h:129
    #5 0x103c6e6a8 in myfunction(mydata*) myfile.cpp:122

SUMMARY: AddressSanitizer: heap-buffer-overflow Memory.h:118 in Eigen::internal::handmade_aligned_free(void*)
Shadow bytes around the buggy address:
  0x007024e27020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007024e27030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007024e27040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007024e27050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007024e27060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x007024e27070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x007024e27080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x007024e27090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x007024e270a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x007024e270b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x007024e270c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==47757==ABORTING
Abort trap: 6

So why is the deallocator called on the correct PointXYZRGB points, but the filter class somehow creates data of type PointXYZL?
The presence or absence of -DPCL_ONLY_CORE_POINT_TYPES=ON and -DNO_EXPLICIT_INSTANTIATIONS makes no difference by the way.

What can I do to debug this?

主要语言
C++
星标
11.2k
派生
4.7k
平均合并
6 天 13 小时
30 天内合并 PR
10

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PointCloudLibrary/pcl 的其他 Issue

查看 PointCloudLibrary/pcl 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。