a very simple PCL+VTK app segfaults

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

a very simple PCL+VTK app segfaults

Cagatay
I have asked a similar question in the past without getting an answer. I run into problems when I try to integrate VTK and PCL libraries in the same application.


Here is the smallest example illustrating my problem. The code compiles but segfaults when run.

//-------------------------------------------
//main.cpp
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>

#include <vtkSmartPointer.h>
#include <vtkPoints.h>

int main() {
  vtkSmartPointer<vtkPoints> v = vtkSmartPointer<vtkPoints>::New();
  pcl::PointCloud<pcl::PointXYZ> cloud;
  return 0;
}

//-------------------------------------------
//CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(VTK_PCL_SegFault)

SET(PCL_DIR "/usr/local/pcl/pclBin-1.7.0")
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})

find_package(VTK  REQUIRED)
include(${VTK_USE_FILE})

ADD_EXECUTABLE(BioSigMQMain main.cpp)
TARGET_LINK_LIBRARIES(BioSigMQMain ${PCL_LIBRARIES} ${VTK_LIBRARIES} )

SET(CMAKE_BUILD_TYPE "Debug")


I ran gdb and here is what I get:

[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00000000004b6b07 in vtkMathInternal::~vtkMathInternal() ()
(gdb) bt
#0  0x00000000004b6b07 in vtkMathInternal::~vtkMathInternal() ()
#1  0x00007fffed94e995 in __cxa_finalize (d=0x7ffff25445e0) at cxa_finalize.c:56
#2  0x00007ffff1cbf8b6 in __do_global_dtors_aux () from /usr/local/pcl/pclBin-1.7.0/lib/libpcl_io.so.1.7
#3  0x0000000000000000 in ?? ()


I have vtk5.10.1 and pcl1-7.0 installed. The problem disappears when I take out pcl library from the code and the cmake file. I am clueless and desperate for any sort of help.

Thank you,
C. Cagatay Bilgin
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Radu B. Rusu
Administrator
There's something wrong with your install. If something as simple as that would crash, all our unit tests would explode, and no PCL code would ever work ;)

I just tried your example on my machine and it worked just fine.

Did you compile PCL by yourself? What VTK version does it link against? In general we recommend first time users to try our binary installations.

My guess is that your PCL was compiled against one version of VTK and you're trying to force another one in the example. Either that or you're mixing and matching different versions of PCL (headers vs libraries).

Best,
Radu.

On Sep 18, 2013, at 4:49 PM, Cagatay <[hidden email]> wrote:

> I have asked a similar question in the past without getting an answer. I run
> into problems when I try to integrate VTK and PCL libraries in the same
> application.
>
>
> Here is the smallest example illustrating my problem. The code compiles but
> segfaults when run.
>
> //-------------------------------------------
> //main.cpp
> #include <pcl/point_types.h>
> #include <pcl/point_cloud.h>
>
> #include <vtkSmartPointer.h>
> #include <vtkPoints.h>
>
> int main() {
>  vtkSmartPointer<vtkPoints> v = vtkSmartPointer<vtkPoints>::New();
>  pcl::PointCloud<pcl::PointXYZ> cloud;
>  return 0;
> }
>
> //-------------------------------------------
> //CMakeLists.txt
> cmake_minimum_required(VERSION 2.6)
> project(VTK_PCL_SegFault)
>
> SET(PCL_DIR "/usr/local/pcl/pclBin-1.7.0")
> find_package(PCL 1.7 REQUIRED)
> include_directories(${PCL_INCLUDE_DIRS})
>
> find_package(VTK  REQUIRED)
> include(${VTK_USE_FILE})
>
> ADD_EXECUTABLE(BioSigMQMain main.cpp)
> TARGET_LINK_LIBRARIES(BioSigMQMain ${PCL_LIBRARIES} ${VTK_LIBRARIES} )
>
> SET(CMAKE_BUILD_TYPE "Debug")
>
>
> I ran gdb and here is what I get:
>
> [Thread debugging using libthread_db enabled]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004b6b07 in vtkMathInternal::~vtkMathInternal() ()
> (gdb) bt
> #0  0x00000000004b6b07 in vtkMathInternal::~vtkMathInternal() ()
> #1  0x00007fffed94e995 in __cxa_finalize (d=0x7ffff25445e0) at
> cxa_finalize.c:56
> #2  0x00007ffff1cbf8b6 in __do_global_dtors_aux () from
> /usr/local/pcl/pclBin-1.7.0/lib/libpcl_io.so.1.7
> #3  0x0000000000000000 in ?? ()
>
>
> I have vtk5.10.1 and pcl1-7.0 installed. The problem disappears when I take
> out pcl library from the code and the cmake file. I am clueless and
> desperate for any sort of help.
>
> Thank you,
> C. Cagatay Bilgin
>
>
>
> --
> View this message in context: http://www.pcl-users.org/a-very-simple-PCL-VTK-app-segfaults-tp4029745.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Cagatay
Hi Radu,

thank you for the prompt response. What version of VTK is installed on your machine? I am using a newer version (5.10.1) than what PCL normally uses (I believe it is 5.4 now). I am thinking that could be the reason. I am pretty confident with cmake and vtk related stuff but have limited experience in pcl. I have fresh installation of vtk5.10.1 on this machine and unless pcl comes bundled with vtk I don't see how I can have more than one installation of vtk.

The precompiled pcl libs come with older versions of vtk (5.4), I cannot use those as they are too old and I have dependencies to the newer vtk version.  
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Cagatay
And yes I compiled everything from source. One other comment is that, the code runs just fine when I don't mix and match the libs. That is, if I run pcl code alone, everything is OK and if I have only vtk code there is no problem.
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Radu B. Rusu
Administrator
In reply to this post by Cagatay

On Sep 18, 2013, at 5:05 PM, Cagatay <[hidden email]> wrote:

> Hi Radu,
>
> thank you for the prompt response.

No problem, that's why we're here.

> What version of VTK is installed on your
> machine? I am using a newer version (5.10.1) than what PCL normally uses (I
> believe it is 5.4 now). I am thinking that could be the reason. I am pretty

I'm running with VTK 5.8, default in Ubuntu 12.10

> confident with cmake and vtk related stuff but have limited experience in
> pcl. I have fresh installation of vtk5.10.1 on this machine and unless pcl
> comes bundled with vtk I don't see how I can have more than one installation
> of vtk.
>
> The precompiled pcl libs come with older versions of vtk (5.4), I cannot use
> those as they are too old and I have dependencies to the newer vtk version.  

Yes, that's the problem. You cannot combine PCL compiled against VTK 5.4 with a newer set of VTK libraries, because VTK releases have not been ABI compatible. Mixing and matching like this can cause crashes in all sorts of different ways, and maybe that's what you're experiencing here?


Best,
Radu.


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Radu B. Rusu
Administrator
In reply to this post by Cagatay

On Sep 18, 2013, at 5:09 PM, Cagatay <[hidden email]> wrote:

> And yes I compiled everything from source. One other comment is that, the
> code runs just fine when I don't mix and match the libs. That is, if I run
> pcl code alone, everything is OK and if I have only vtk code there is no
> problem.

To fix this, you'd need to compile PCL against the newer version of VTK. There's no other solution.

Best,
Radu.


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Cagatay


That is exactly what I am doing. When I am compiling PCL, I point the VTK_DIR to the vtk5.10.1. So PCL is compiled against vtk5.10.1. In my application I set the vtk_dir to 5.10.1 as well. I can provide my CMakeCache.txt for the pcl installation if that would help.
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Cagatay
Just tried this on a new machine. Compiled fresh vtk5.10.1 from source and fresh pcl-1.6.0 from source, pointing to the only vtk installation I have (5.10.1). I am running the code I provided before and getting the same segfault:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004bd467 in vtkMathInternal::~vtkMathInternal() ()
(gdb) bt
#0  0x00000000004bd467 in vtkMathInternal::~vtkMathInternal() ()
#1  0x00007fffef3fd995 in __cxa_finalize (d=0x7ffff48b62e0) at cxa_finalize.c:56
#2  0x00007ffff4220b26 in __do_global_dtors_aux () from /usr/local/pcl/pclBin-1.6.0/lib/libpcl_io.so.1.6
#3  0x0000000000000000 in ?? ()


One thing I realized that during the PCL installation I got tons of offsetof warnings. Not sure if it is related:
/usr/local/pcl/pcl-1.6.0/common/include/pcl/point_types.h:551: warning: (perhaps the ‘offsetof’ macro was used incorrectly)

I depend on vtk and pcl so much that I cannot drop either. This is going to be too costly for me. Wish I knew more about the inner workings of pcl a little better.
Reply | Threaded
Open this post in threaded view
|

Re: a very simple PCL+VTK app segfaults

Radu B. Rusu
Administrator
In reply to this post by Cagatay
Yeah, sending over the CMakeCache might be good (or pasting it somewhere online).

Also, you can ldd any PCL executables, to see if they actually do point to VTK 5.10.

Best,
Radu.

On Sep 18, 2013, at 5:16 PM, Cagatay <[hidden email]> wrote:

>
>
> That is exactly what I am doing. When I am compiling PCL, I point the
> VTK_DIR to the vtk5.10.1. So PCL is compiled against vtk5.10.1. In my
> application I set the vtk_dir to 5.10.1 as well. I can provide my
> CMakeCache.txt for the pcl installation if that would help.
>
>
>
>
> --
> View this message in context: http://www.pcl-users.org/a-very-simple-PCL-VTK-app-segfaults-tp4029745p4029751.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users