eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.68k stars 393 forks source link

Error with publishcopyof #2166

Closed lhxsm closed 10 months ago

lhxsm commented 10 months ago

When I use publishcopyof for sending custom structures with a structure size of 80, it crashes. how do I configure this, I am using the default toml file.

elBoberido commented 10 months ago

Do you have more information for us, e.g.

lhxsm commented 10 months ago

Do you have more information for us, e.g.

  • which iceoryx version
  • which OS
  • where does the crash happen, on the publisher or subscriber
  • do you have a backtrace
  • can you share the content of the struct (the data which can be transferred with shared memory underlies some restrictions)

Yes,the iceoryx version is 2.0.4, and under Ubuntu 18.04. just when using publishCopyOf to publish the structures, like as: void xxx::publishData(const MyStruct &data) { publisher.publishCopyOf(data); } then run application, crash...... BUT, If the structure is defined simply, for example: struct A { int a; } the fucniton works right.

lhxsm commented 10 months ago

backtrace *** Segmentation fault

Register dump: PC(Program-Counter): 0000007f7fcc7ef4 LR(Link-Register): 000000000041ade8 FP(Frame-Pointer): 0000007f7f9225a0 SP(Stack-Pointer): 0000007f7f9225a0 CPSR(Process-State): 0000000060001000 Fault Addr: 0000000000000000 X0: 0000000000000000 X1: 0000007f70001128 X2: 0000000000000000 X3: 0000000000000000 X4: 0000000000423ba4 X5: 0000007f7fe4b180 X6: 0000007f63114000 X7: 0000007f7fe4ad90 X8: 0000007f7f922540 X9: 7878787878787878 X10: 0000000000000000 X11: 0000000000000018 X12: 7878787878787878 X13: 0000007f7fc031a8 X14: 0000007f7fbe2898 X15: 0000007f70003663 X16: 0000007f7fcc7e74 X17: 000000000043d0a0 X18: 0000007f7faa8008 X19: 0000007f63114048 X20: 0000000000000000 X21: 0000007f70001128 X22: 0000007f70000f30 X23: 0000007f7f922730 X24: 0000000000423449 X25: 0000007f70001090 X26: 0000007f70000f30 X27: 0000007f7f9227d8 X28: 0000007f70000ff0 Backtrace: /usr/lib64/libstdc++.so.6(_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_MassignERKS4+0x80)[0x7f7fcc7ef4] ./mcuengine(_ZZN3iox3cxx12function_refIFvRNS_4popo6SampleI10ice_ObjectNS_5mepoo12NoUserHeaderEEEEEC4IZNS2_13PublisherImplIS4_S6_NS2_13BasePublisherINS2_17PublisherPortUserEEEE13publishCopyOfERKS4_EUlRT_E_vEEOSJ_ENUlPvS8_E_4_FUNESNS8+0x60)[0x41ade8] ./mcuengine(_ZN3iox4popo13PublisherImplI10ice_ObjectNS_5mepoo12NoUserHeaderENS0_13BasePublisherINS017PublisherPortUserEEEE13publishCopyOfERKS2+0x70)[0x41abd8] ./mcuengine(_ZN16IceoryxPublisher17publishStructDataERK10ice_Object+0x44)[0x41a678] ./mcuengine(_ZN9DataWrite19write_0x174_ppsDataERSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiSt4lessIS6_ESaISt4pairIKS6_iEEEh+0x3c4)[0x41c024] ./mcuengine(_ZN11CANAnalysis16parse_0x174_DataB5cxx11EPKhhh+0x1b4)[0x4179e0] ./mcuengine(_ZN11CANAnalysis12parseCanDataB5cxx11EjRKSt6vectorIhSaIhEEhh+0xfc)[0x4192a0] ./mcuengine(_ZN10CanManager14processMessageERKSt10unique_ptrI7MessageSt14default_deleteIS1_EE+0x180)[0x41ed3c] ./mcuengine(_ZN10McuManager15dispatchMessageEv+0x17c)[0x414320]

elBoberido commented 10 months ago

@lhxsm can you share the data structure you want to publish or at least create one which also triggers the crash based on your custom type? I'm not quite sure but may it be that a std::string is part of your custom type?

lhxsm commented 10 months ago

@lhxsm can you share the data structure you want to publish or at least create one which also triggers the crash based on your custom type? I'm not quite sure but may it be that a std::string is part of your custom type?

@elBoberido yes, there is a std::string field in!!!!, I commented out this field and it works fine. what should I do if I need to use std::string? use a char array instead?

mossmaurice commented 10 months ago

@lhxsm

Unfortunately sending a std::string won't work (unless you serialize it yourself) as it's using the process local heap. There are a few more restrictions on the types that can be sent through iceoryx. They are documented here.

what should I do if I need to use std::string? use a char array instead?

As a replacement for std::string you can, for example, use the fixed-size iox::string.

elBoberido commented 10 months ago

Closing the issue. As @mossmaurice already mentioned, there are restrictions on what can be published with shared memory. For alternatives to STL container and vocabulary types please have a look at iceoryx_hoofs

lhxsm commented 10 months ago

@mossmaurice @elBoberido Got it,thanks

elBoberido commented 10 months ago

@lhxsm btw, i'm now shamelessly advertising my upcoming startup ;) Mainly because it will be the only one which is providing commercial support for eclipse-iceoryx. It will be added to the README once it is official and of course every company offering iceoryx support has the right to be added to the README. But back to the off-topic. If you are working for a company and need a deep dive into iceoryx or training or other support, you can reach me via my github profile.