title: seg fault static class member pointer used with dynamic allocation
body: <p>I am running into seg fault as shown</p>
  <pre><code>cluster_init: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = pcl::PointCloud&lt;pcl::PointXYZ&gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = pcl::PointCloud&lt;pcl::PointXYZ&gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  </code></pre>
  <p>I pinpoint my problem and i suspect it has something to do with my use of a static class which has purely only static members and static functions. I am pretty sure the problem arises from the member mCoefficients as the code was working before i implemented that part.<br />
  How would i initialise the static member mCoefficients so that i do not run into this seg fault? I have tried initialising it in the cpp file while having its declaration in the header file but it does not seem to be working.</p>
  <pre><code>#ifndef POINTCLOUDPROCESSOR_H
  #define POINTCLOUDPROCESSOR_H
  
  // Include the ROS library
  #include &lt;ros/ros.h&gt;
  #include &lt;pcl_ros/point_cloud.h&gt; 
  
  // Include pcl
  #include &lt;pcl/point_cloud.h&gt;
  #include &lt;pcl/point_types.h&gt;
  #include &lt;pcl/filters/passthrough.h&gt;
  #include &lt;pcl/filters/crop_box.h&gt;
  #include &lt;pcl/filters/project_inliers.h&gt;
  #include &lt;pcl/ModelCoefficients.h&gt;
  
  namespace ocb
  {
  typedef pcl::PointCloud&lt;pcl::PointXYZ&gt;::Ptr type_pclcloudptr;
  class PointCloudProcessor
  {
    public:
  
    static type_pclcloudptr ROS_to_PCL(sensor_msgs::PointCloud2Ptr&amp; ros_msg);
    static type_pclcloudptr transform_frame(type_pclcloudptr&amp; sourcecloud,Eigen::Affine3f&amp; transform); 
    static type_pclcloudptr merge_pointclouds(type_pclcloudptr&amp; msg1, type_pclcloudptr&amp; msg2, type_pclcloudptr&amp; msg3, type_pclcloudptr&amp; msg4);
  
    static type_pclcloudptr groundbus_removal(type_pclcloudptr&amp; input);
    static void init_passfilter();
    static void init_plane_transform();
    static type_pclcloudptr planar_transformation(type_pclcloudptr&amp; input);
  
    private:
  
    static pcl::PassThrough&lt;pcl::PointXYZ&gt; mGroundAirfilter;
    static pcl::CropBox&lt;pcl::PointXYZ&gt; mBusfilter;
    static pcl::ModelCoefficients::Ptr mCoefficients;
    static pcl::ProjectInliers&lt;pcl::PointXYZ&gt; mProj;
  
  };
  } //namespace close scope
  
  #endif //for POINTCLOUDPROCESSOR_H
  </code></pre>
  <pre><code>#include &lt;PointCloudProcessor.h&gt;
  #include &lt;pcl/common/transforms.h&gt;
  #include &lt;pcl_conversions/pcl_conversions.h&gt;
  #include &lt;pcl/common/io.h&gt;
  
  namespace ocb
  {
    pcl::PassThrough&lt;pcl::PointXYZ&gt; PointCloudProcessor::mGroundAirfilter;
    pcl::CropBox&lt;pcl::PointXYZ&gt; PointCloudProcessor::mBusfilter;
    pcl::ModelCoefficients::Ptr PointCloudProcessor::mCoefficients(new pcl::ModelCoefficients);
    pcl::ProjectInliers&lt;pcl::PointXYZ&gt; PointCloudProcessor::mProj;
    type_pclcloudptr PointCloudProcessor::ROS_to_PCL(sensor_msgs::PointCloud2Ptr&amp; ros_msg)
    { 
      type_pclcloudptr pcl_msg(new pcl::PointCloud&lt;pcl::PointXYZ&gt;);
      pcl::fromROSMsg(*ros_msg, *pcl_msg);
      return pcl_msg;
    }
    type_pclcloudptr PointCloudProcessor::transform_frame(type_pclcloudptr&amp; sourcecloud,Eigen::Affine3f&amp; transform)
    {
      type_pclcloudptr destcloud(new pcl::PointCloud&lt;pcl::PointXYZ&gt;);
      pcl::transformPointCloud(*sourcecloud, *destcloud,transform);
      return destcloud;
    }
    type_pclcloudptr PointCloudProcessor::merge_pointclouds(type_pclcloudptr&amp; msg1, type_pclcloudptr&amp; msg2, type_pclcloudptr&amp; msg3, type_pclcloudptr&amp; msg4)
    {
      type_pclcloudptr mergedcloud(new pcl::PointCloud&lt;pcl::PointXYZ&gt;); 
      
      mergedcloud = msg1;
      *mergedcloud += *msg2;
      *mergedcloud += *msg3;
      *mergedcloud += *msg4;
      return mergedcloud;
    }
    type_pclcloudptr PointCloudProcessor::groundbus_removal(type_pclcloudptr&amp; input)
    {
      type_pclcloudptr filtered_cloud1(new pcl::PointCloud&lt;pcl::PointXYZ&gt;);
      type_pclcloudptr filtered_cloud2(new pcl::PointCloud&lt;pcl::PointXYZ&gt;);
      PointCloudProcessor::mGroundAirfilter.setInputCloud(input);
      PointCloudProcessor::mGroundAirfilter.filter(*filtered_cloud1);
      PointCloudProcessor::mBusfilter.setInputCloud(filtered_cloud1);
      PointCloudProcessor::mBusfilter.filter(*filtered_cloud2);
      return filtered_cloud2;
    }
    void PointCloudProcessor::init_passfilter()
    {
      PointCloudProcessor::mGroundAirfilter.setFilterFieldName(&quot;z&quot;);
      PointCloudProcessor::mGroundAirfilter.setFilterLimits(0.5 , 4.2);
      PointCloudProcessor::mGroundAirfilter.setFilterLimitsNegative (false);
      PointCloudProcessor::mBusfilter.setMin(Eigen::Vector4f(-2.0, -1.75, 0.0, 1.0));
      PointCloudProcessor::mBusfilter.setMax(Eigen::Vector4f(5.9, 1.75, 3.5, 1.0));
      PointCloudProcessor::mBusfilter.setNegative(true);
    }
    void PointCloudProcessor::init_plane_transform()
    {
      PointCloudProcessor::mCoefficients-&gt;values.resize(4);
      PointCloudProcessor::mCoefficients-&gt;values[0] = 0.0;
      PointCloudProcessor::mCoefficients-&gt;values[1] = 0.0;
      PointCloudProcessor::mCoefficients-&gt;values[2] = 1.0;
      PointCloudProcessor::mCoefficients-&gt;values[3] = 0.0;
      PointCloudProcessor::mProj.setModelCoefficients(PointCloudProcessor::mCoefficients);
      PointCloudProcessor::mProj.setModelType(pcl::SACMODEL_PLANE);
    }
    type_pclcloudptr PointCloudProcessor::planar_transformation(type_pclcloudptr&amp; input)
    {
      type_pclcloudptr filtered_cloud(new pcl::PointCloud&lt;pcl::PointXYZ&gt;);
      PointCloudProcessor::mProj.setInputCloud(input);
      PointCloudProcessor::mProj.filter(*filtered_cloud);
      return filtered_cloud;
    }
  
  }
  </code></pre>