Creation of connection results in segfault

Hi,

I developed a transport plugin to work with ros-msgs, but during the creation
I get a segfault which I cannot explain, a backtrace below:

#0 0x0000000000647c80 in ?? ()
#1 0x00007ffff727caf9 in RTT::base::InputPortInterface::channelReady
(this=0x673100,
channel=...)
at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
git/rtt/base/InputPortInterface.cpp:98
#2 0x00007ffff72887a2 in RTT::internal::ConnFactory::createAndCheckStream
(input_port=...,
policy=..., outhalf=..., conn_id=0x63b330)
at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
git/rtt/internal/ConnFactory.cpp:189
#3 0x00007fffddf3b45d in
RTT::internal::ConnFactory::createStream<std_msgs::Float64_<std::allocator<void>
> > (input_port=..., policy=...)
at /home/rsmits/ros/kul-ros-
pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../internal/ConnFactory.hpp:280
#4 0x00007fffddf37c7f in
RTT::InputPort<std_msgs::Float64_<std::allocator<void> > >::createStream
(this=0x673100, policy=...)
at /home/rsmits/ros/kul-ros-
pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../InputPort.hpp:150

The important part of the transport code of my plugin:

RosSubChannelElement(base::PortInterface* port, const ConnPolicy& policy):
newdata(false),init(false)
{
ros_sub=ros_node.subscribe(policy.name_id,policy.size,&RosSubChannelElement::newData,this);
}

~RosSubChannelElement() {
}

virtual bool inputReady() {
log(Info)<<"inputReady?"<<endlog();
return true;
}

I also get the following error comming from ROS:

[ WARN] [1279799305.223531900]: Subscriber on '/float_in' destroyed immediately
after creation. Did you forget to store the handle?

This error is issued when a subscriber gets destroyed within 0.001s after
creation, the subscriber can only be desctructed at destruction of my
RosSubChannelElement, I think the destruction of the ChannelElement causes the
segfault, but I cannot find the reason for this destruction.

Ruben

Ruben Smits's picture

Creation of connection results in segfault

On Thursday 22 July 2010 13:56:31 Ruben Smits wrote:
> Hi,
>
> I developed a transport plugin to work with ros-msgs, but during the
> creation I get a segfault which I cannot explain, a backtrace below:
>

Now I've got some extra debug lines, the problem apparently appears in the
inputReady function, but since my inputReady function just logs and returns
true I still have no clue:

#0 0x00007fffe400b2c0 in ?? ()
#1 0x00007ffff728101c in RTT::base::ChannelElementBase::inputReady
(this=0x7fffe4002630)
at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
git/rtt/base/ChannelInterface.cpp:102
#2 0x00007ffff727caf9 in RTT::base::InputPortInterface::channelReady
(this=0x7fffe400e410,
channel=...)
at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
git/rtt/base/InputPortInterface.cpp:98
#3 0x00007ffff72887a2 in RTT::internal::ConnFactory::createAndCheckStream
(input_port=...,
policy=..., outhalf=..., conn_id=0x7fffe400adc0)
at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
git/rtt/internal/ConnFactory.cpp:189
#4 0x00007fffdc57945d in
RTT::internal::ConnFactory::createStream<std_msgs::Float64_<std::allocator<void>
> > (input_port=..., policy=...)
at /home/rsmits/ros/kul-ros-
pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../internal/ConnFactory.hpp:280
#5 0x00007fffdc575c7f in
RTT::InputPort<std_msgs::Float64_<std::allocator<void> > >::createStream
(this=0x7fffe400e410, policy=...)
at /home/rsmits/ros/kul-ros-
pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../InputPort.hpp:150

> #0 0x0000000000647c80 in ?? ()
> #1 0x00007ffff727caf9 in RTT::base::InputPortInterface::channelReady
> (this=0x673100,
> channel=...)
> at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
> git/rtt/base/InputPortInterface.cpp:98
> #2 0x00007ffff72887a2 in RTT::internal::ConnFactory::createAndCheckStream
> (input_port=...,
> policy=..., outhalf=..., conn_id=0x63b330)
> at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
> git/rtt/internal/ConnFactory.cpp:189
> #3 0x00007fffddf3b45d in
> RTT::internal::ConnFactory::createStream<std_msgs::Float64_<std::allocator<
> void>
>
> > > (input_port=..., policy=...)
>
> at /home/rsmits/ros/kul-ros-
> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../internal/ConnFactory.hp
> p:280 #4 0x00007fffddf37c7f in
> RTT::InputPort<std_msgs::Float64_<std::allocator<void> > >::createStream
> (this=0x673100, policy=...)
> at /home/rsmits/ros/kul-ros-
> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../InputPort.hpp:150
>
>
> The important part of the transport code of my plugin:
>
> RosSubChannelElement(base::PortInterface* port, const ConnPolicy& policy):
> newdata(false),init(false)
> {
>
> ros_sub=ros_node.subscribe(policy.name_id,policy.size,&RosSubChannelElemen
> t::newData,this); }
>
> ~RosSubChannelElement() {
> }
>
> virtual bool inputReady() {
> log(Info)<<"inputReady?"<<endlog();
> return true;
> }
>
> I also get the following error comming from ROS:
>
> [ WARN] [1279799305.223531900]: Subscriber on '/float_in' destroyed
> immediately after creation. Did you forget to store the handle?
>
> This error is issued when a subscriber gets destroyed within 0.001s after
> creation, the subscriber can only be desctructed at destruction of my
> RosSubChannelElement, I think the destruction of the ChannelElement causes
> the segfault, but I cannot find the reason for this destruction.
>
> Ruben

Creation of connection results in segfault

Hi Ruben,

Sylvain and I looked at your problem. We will fix it cleanly before
the final release, but your work-around now is to have this code in
your RosSubChannelElement constructor (*not* in the 'Pub' version):

this->ref();

Peter

On Thu, Jul 22, 2010 at 3:31 PM, Ruben Smits
<ruben [dot] smits [..] ...> wrote:
> On Thursday 22 July 2010 13:56:31 Ruben Smits wrote:
>>  Hi,
>>
>> I developed a transport plugin to work with ros-msgs, but during the
>> creation I get a segfault which I cannot explain, a backtrace below:
>>
>
> Now I've got some extra debug lines, the problem apparently appears in the
> inputReady function, but since my inputReady function just logs and returns
> true I still have no clue:
>
> #0  0x00007fffe400b2c0 in ?? ()
> #1  0x00007ffff728101c in RTT::base::ChannelElementBase::inputReady
> (this=0x7fffe4002630)
>    at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
> git/rtt/base/ChannelInterface.cpp:102
> #2  0x00007ffff727caf9 in RTT::base::InputPortInterface::channelReady
> (this=0x7fffe400e410,
>    channel=...)
>    at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
> git/rtt/base/InputPortInterface.cpp:98
> #3  0x00007ffff72887a2 in RTT::internal::ConnFactory::createAndCheckStream
> (input_port=...,
>    policy=..., outhalf=..., conn_id=0x7fffe400adc0)
>    at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
> git/rtt/internal/ConnFactory.cpp:189
> #4  0x00007fffdc57945d in
> RTT::internal::ConnFactory::createStream<std_msgs::Float64_<std::allocator<void>
>> > (input_port=..., policy=...)
>    at /home/rsmits/ros/kul-ros-
> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../internal/ConnFactory.hpp:280
> #5  0x00007fffdc575c7f in
> RTT::InputPort<std_msgs::Float64_<std::allocator<void> > >::createStream
> (this=0x7fffe400e410, policy=...)
>    at /home/rsmits/ros/kul-ros-
> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../InputPort.hpp:150
>
>
>> #0  0x0000000000647c80 in ?? ()
>> #1  0x00007ffff727caf9 in RTT::base::InputPortInterface::channelReady
>> (this=0x673100,
>>     channel=...)
>>     at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
>> git/rtt/base/InputPortInterface.cpp:98
>> #2  0x00007ffff72887a2 in RTT::internal::ConnFactory::createAndCheckStream
>> (input_port=...,
>>     policy=..., outhalf=..., conn_id=0x63b330)
>>     at /home/rsmits/ros/kul-ros-pkg/orocos/rtt/rtt_2.0/rtt_2.0-
>> git/rtt/internal/ConnFactory.cpp:189
>> #3  0x00007fffddf3b45d in
>> RTT::internal::ConnFactory::createStream<std_msgs::Float64_<std::allocator<
>> void>
>>
>> > > (input_port=..., policy=...)
>>
>>     at /home/rsmits/ros/kul-ros-
>> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../internal/ConnFactory.hp
>> p:280 #4  0x00007fffddf37c7f in
>> RTT::InputPort<std_msgs::Float64_<std::allocator<void> > >::createStream
>> (this=0x673100, policy=...)
>>     at /home/rsmits/ros/kul-ros-
>> pkg/orocos/rtt/rtt_2.0/install/include/rtt/types/../InputPort.hpp:150
>>
>>
>> The important part of the transport code of my plugin:
>>
>> RosSubChannelElement(base::PortInterface* port, const ConnPolicy& policy):
>>     newdata(false),init(false)
>>     {
>>
>> ros_sub=ros_node.subscribe(policy.name_id,policy.size,&RosSubChannelElemen
>> t::newData,this); }
>>
>>     ~RosSubChannelElement() {
>>     }
>>
>>     virtual bool inputReady() {
>>       log(Info)<<"inputReady?"<<endlog();
>>       return true;
>>     }
>>
>> I also get the following error comming from ROS:
>>
>> [ WARN] [1279799305.223531900]: Subscriber on '/float_in' destroyed
>> immediately after creation.  Did you forget to store the handle?
>>
>> This error is issued when a subscriber gets destroyed within 0.001s after
>> creation, the subscriber can only be desctructed at destruction of my
>> RosSubChannelElement, I think the destruction of the ChannelElement causes
>> the segfault, but I cannot find the reason for this destruction.
>>
>> Ruben
> --
> Orocos-Dev mailing list
> Orocos-Dev [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
>
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev