index operator for datatype with containing fixed-size carray segfaults

Hi,

I have a struct containing a fixed size c-array ala:

struct KRLData{
float realData[16];
int intData[16];
uint16 boolData;
uint8 fill;
}

I created a typekit for it using typegen,

now if I want to use the index operator for the arrays in the taskbrowser I
get the following segfault:

In Task Robot[U]
(type 'ls' for context info) :fromKRL
Got :fromKRL
= {realData = {size = 16, capacity = 16 }, intData = {size = 16, capacity =
16 }, boolData = (unknown_t), fill = (unknown_t) }

In Task Robot[U]
(type 'ls' for context info) :fromKRL.realData[0]
Got :fromKRL.realData[0]
deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
boost::intrusive_ptr<T>::operator->() const [with T =
RTT::internal::DataSource<unsigned int>]: Assertion `px != 0' failed.

The backtrace:

bt
#0 0x00007ffff4caea75 in *__GI_raise (sig=<value optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff4cb25c0 in *__GI_abort () at abort.c:92
#2 0x00007ffff4ca7941 in *__GI___assert_fail (assertion=0x7ffff18745a6 "px != 0",
file=<value optimized out>, line=166,
function=0x7ffff1888460 "T* boost::intrusive_ptr<T>::operator->() const
[with T = RTT::internal::DataSource<unsigned int>]") at assert.c:81
#3 0x00007ffff175ebde in
RTT::types::CArrayTypeInfo<RTT::internal::carray<float>,
false>::getMember(boost::intrusive_ptr<RTT::base::DataSourceBase>,
boost::intrusive_ptr<RTT::base::DataSourceBase>) const ()
from /home/rsmits/ros/private-kul-ros-
pkg/kuka_lwr_fri_typekit/lib/orocos/types/libkuka_lwr_fri_typekit-typekit-
gnulinux.so
#4 0x00007ffff730caee in RTT::base::DataSourceBase::getMember (this=<value
optimized out>, part_id=..., offset=<value optimized out>)
at /home/rsmits/ros/kul-ros-
pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
rtt/rtt/internal/DataSource.cpp:116
#5 0x00007ffff5dffd02 in RTT::scripting::ExpressionParser::seen_index
(this=0x7fffffffcb50)
at /home/rsmits/ros/kul-ros-
pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
rtt/rtt/scripting/ExpressionParser.cpp:612

The rest of the backtrace is some pages contain boost::spirit commands.

Did I do something wrong, I'm I trying to do something which is not possible
or did I bump onto a bug?

Ruben

index operator for datatype with containing fixed-size carray se

On Thursday 07 October 2010 20:56:23 Ruben Smits wrote:
> Hi,
>
> I have a struct containing a fixed size c-array ala:
>
> struct KRLData{
> float realData[16];
> int intData[16];
> uint16 boolData;
> uint8 fill;
> }
>
> I created a typekit for it using typegen,
>
> now if I want to use the index operator for the arrays in the taskbrowser I
> get the following segfault:
>
> In Task Robot[U]
> (type 'ls' for context info) :fromKRL
> Got :fromKRL
> = {realData = {size = 16, capacity = 16 }, intData = {size = 16, capacity
> = 16 }, boolData = (unknown_t), fill = (unknown_t) }
>
> In Task Robot[U]
> (type 'ls' for context info) :fromKRL.realData[0]
> Got :fromKRL.realData[0]
> deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
> boost::intrusive_ptr<T>::operator->() const [with T =
> RTT::internal::DataSource<unsigned int>]: Assertion `px != 0' failed.

Two bugs were here: first, the contents were not shown of this array. Second,
if you provided something in [...] it didn't expect, it crashed during the
log(Error) message :-]

I've pushed these fixes + some others to the toolchain-2.0 branch.

The remaining problem is that we need to standardize on what the 'size' of an
array is: an 'int' / int32_t or an 'unsigned int' / uint32_t. Especially,
since you'll get annoying warning messages when going automatically from int -
> uint.

NOTE as well: you can not 'deep' copy fixed array types in scripting. It will
only copy the pointer so writing 'a = b' will cause that a change to 'b' will
cause the identical change to 'a'.

I'm betting you don't want this...

Peter

index operator for datatype with containing fixed-size carray se

On Oct 8, 2010, at 06:42 , Peter Soetens wrote:

> On Thursday 07 October 2010 20:56:23 Ruben Smits wrote:
>> Hi,
>>
>> I have a struct containing a fixed size c-array ala:
>>
>> struct KRLData{
>> float realData[16];
>> int intData[16];
>> uint16 boolData;
>> uint8 fill;
>> }
>>
>> I created a typekit for it using typegen,
>>
>> now if I want to use the index operator for the arrays in the taskbrowser I
>> get the following segfault:
>>
>> In Task Robot[U]
>> (type 'ls' for context info) :fromKRL
>> Got :fromKRL
>> = {realData = {size = 16, capacity = 16 }, intData = {size = 16, capacity
>> = 16 }, boolData = (unknown_t), fill = (unknown_t) }
>>
>> In Task Robot[U]
>> (type 'ls' for context info) :fromKRL.realData[0]
>> Got :fromKRL.realData[0]
>> deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
>> boost::intrusive_ptr<T>::operator->() const [with T =
>> RTT::internal::DataSource<unsigned int>]: Assertion `px != 0' failed.
>
> Two bugs were here: first, the contents were not shown of this array. Second,
> if you provided something in [...] it didn't expect, it crashed during the
> log(Error) message :-]
>
> I've pushed these fixes + some others to the toolchain-2.0 branch.
>
> The remaining problem is that we need to standardize on what the 'size' of an
> array is: an 'int' / int32_t or an 'unsigned int' / uint32_t. Especially,
> since you'll get annoying warning messages when going automatically from int -
>> uint.

Orocos as a whole doesn't have support for any unsigned quantities in scripting, etc, right? If so, seems best to stay signed here.

> NOTE as well: you can not 'deep' copy fixed array types in scripting. It will
> only copy the pointer so writing 'a = b' will cause that a change to 'b' will
> cause the identical change to 'a'.
>
> I'm betting you don't want this...

+1
S

index operator for datatype with containing fixed-size carray se

2010/10/7 Ruben Smits <ruben [dot] smits [..] ...>:
>  Hi,
>
> I have a struct containing a fixed size c-array ala:
>
> struct KRLData{
>  float realData[16];
>  int intData[16];
>  uint16 boolData;
>  uint8 fill;
> }
>
> I created a typekit for it using typegen,
>
> now if I want to use the index operator for the arrays in the taskbrowser I
> get the following segfault:
>
> In Task Robot[U]
>  (type 'ls' for context info) :fromKRL
>      Got :fromKRL
>  = {realData = {size = 16, capacity = 16 }, intData = {size = 16, capacity =
> 16 }, boolData = (unknown_t), fill = (unknown_t) }
>
> In Task Robot[U]
>  (type 'ls' for context info) :fromKRL.realData[0]
>      Got :fromKRL.realData[0]
> deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
> boost::intrusive_ptr<T>::operator->() const [with T =
> RTT::internal::DataSource<unsigned int>]: Assertion `px != 0' failed.
>
> The backtrace:
>
> bt
> #0  0x00007ffff4caea75 in *__GI_raise (sig=<value optimized out>) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> #1  0x00007ffff4cb25c0 in *__GI_abort () at abort.c:92
> #2  0x00007ffff4ca7941 in *__GI___assert_fail (assertion=0x7ffff18745a6 "px != 0",
> file=<value optimized out>, line=166,
>    function=0x7ffff1888460 "T* boost::intrusive_ptr<T>::operator->() const
> [with T = RTT::internal::DataSource<unsigned int>]") at assert.c:81
> #3  0x00007ffff175ebde in
> RTT::types::CArrayTypeInfo<RTT::internal::carray<float>,
> false>::getMember(boost::intrusive_ptr<RTT::base::DataSourceBase>,
> boost::intrusive_ptr<RTT::base::DataSourceBase>) const ()
>   from /home/rsmits/ros/private-kul-ros-
> pkg/kuka_lwr_fri_typekit/lib/orocos/types/libkuka_lwr_fri_typekit-typekit-
> gnulinux.so
> #4  0x00007ffff730caee in RTT::base::DataSourceBase::getMember (this=<value
> optimized out>, part_id=..., offset=<value optimized out>)
>    at /home/rsmits/ros/kul-ros-
> pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
> rtt/rtt/internal/DataSource.cpp:116
> #5  0x00007ffff5dffd02 in RTT::scripting::ExpressionParser::seen_index
> (this=0x7fffffffcb50)
>    at /home/rsmits/ros/kul-ros-
> pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
> rtt/rtt/scripting/ExpressionParser.cpp:612
>
>
> The rest of the backtrace is some pages contain boost::spirit commands.
>
> Did I do something wrong, I'm I trying to do something which is not possible
> or did I bump onto a bug?

I think this is because you have not implemented the [] operator.
Peter replied to me once how to do it, but I haven't tested it yet.
See orocos-dev mailing list topic 'getProperty<classT> functionality'
dating augustus 19th.

Steven

>
> Ruben
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

index operator for datatype with containing fixed-size carray se

On Thursday 07 October 2010 21:20:18 Steven Bellens wrote:
> 2010/10/7 Ruben Smits <ruben [dot] smits [..] ...>:
> > Hi,
> >
> > I have a struct containing a fixed size c-array ala:
> >
> > struct KRLData{
> > float realData[16];
> > int intData[16];
> > uint16 boolData;
> > uint8 fill;
> > }
> >
> > I created a typekit for it using typegen,
> >
> > now if I want to use the index operator for the arrays in the taskbrowser
> > I get the following segfault:
> >
> > In Task Robot[U]
> > (type 'ls' for context info) :fromKRL
> > Got :fromKRL
> > = {realData = {size = 16, capacity = 16 }, intData = {size = 16,
> > capacity = 16 }, boolData = (unknown_t), fill = (unknown_t) }
> >
> > In Task Robot[U]
> > (type 'ls' for context info) :fromKRL.realData[0]
> > Got :fromKRL.realData[0]
> > deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
> > boost::intrusive_ptr<T>::operator->() const [with T =
> > RTT::internal::DataSource<unsigned int>]: Assertion `px != 0' failed.
> >
> > The backtrace:
> >
> > bt
> > #0 0x00007ffff4caea75 in *__GI_raise (sig=<value optimized out>) at
> > ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> > #1 0x00007ffff4cb25c0 in *__GI_abort () at abort.c:92
> > #2 0x00007ffff4ca7941 in *__GI___assert_fail (assertion=0x7ffff18745a6
> > "px != 0", file=<value optimized out>, line=166,
> > function=0x7ffff1888460 "T* boost::intrusive_ptr<T>::operator->()
> > const [with T = RTT::internal::DataSource<unsigned int>]") at
> > assert.c:81 #3 0x00007ffff175ebde in
> > RTT::types::CArrayTypeInfo<RTT::internal::carray<float>,
> > false>::getMember(boost::intrusive_ptr<RTT::base::DataSourceBase>,
> > boost::intrusive_ptr<RTT::base::DataSourceBase>) const ()
> > from /home/rsmits/ros/private-kul-ros-
> > pkg/kuka_lwr_fri_typekit/lib/orocos/types/libkuka_lwr_fri_typekit-typekit
> > - gnulinux.so
> > #4 0x00007ffff730caee in RTT::base::DataSourceBase::getMember
> > (this=<value optimized out>, part_id=..., offset=<value optimized out>)
> > at /home/rsmits/ros/kul-ros-
> > pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
> > rtt/rtt/internal/DataSource.cpp:116
> > #5 0x00007ffff5dffd02 in RTT::scripting::ExpressionParser::seen_index
> > (this=0x7fffffffcb50)
> > at /home/rsmits/ros/kul-ros-
> > pkg/stacks/orocos_toolchain_ros/rtt/build/orocos-toolchain-
> > rtt/rtt/scripting/ExpressionParser.cpp:612
> >
> >
> > The rest of the backtrace is some pages contain boost::spirit commands.
> >
> > Did I do something wrong, I'm I trying to do something which is not
> > possible or did I bump onto a bug?
>
> I think this is because you have not implemented the [] operator.
> Peter replied to me once how to do it, but I haven't tested it yet.
> See orocos-dev mailing list topic 'getProperty<classT> functionality'
> dating augustus 19th.

This is not the cause. All Sequence/Array type info implement operator[]
automatically (getMember() implements that). Ruben has hit a bug, I'll fix it
tomorrow/day.

Peter