#64 segfault when no Carrier is found

closed-fixed
General (20)
5
2009-11-02
2009-10-29
Lorenzo G
No

Due to a (probable) misconfiguration in ACE tools, I get a segmentation fault when running yarp check (server is running fine). I investigated and the problem seems to be also related to an issue in a source file.

Debug output is attached as file out.txt.

I checked the source code and it I think there's a mistake in the Carriers::chooseCarrier() method (file yarp2/src/libYARP_OS/src/Carriers.cpp). It reads:

unsigned int i = YARP_STRSTR(s,"+");

but it should be:

size_t i = YARP_STRSTR(s, "+");

because YARP_STRSTR is defined in src/libYARP_OS/include/yarp/os/impl/String.h as:

#define YARP_STRSTR(yahstack, needle) (haystack).find(needle)

where (haystack) is of type String, being it in yarp::os::impl::std::string

and it should return a signed integer, as specified in http://www.cplusplus.com/reference/string/string/find/

Changing the above line returns the expected behaviour (i.e. an error due to mt ACE misconfiguration, and not a segfault altogether).

Discussion

  • Lorenzo G

    Lorenzo G - 2009-10-29
     
  • Lorenzo G

    Lorenzo G - 2009-10-29

    forgot to mention, when debugging the error the following values might also help:

    (gdb) print s
    $6 = {<ACE_String_Base_Const> = {static npos = 18446744073709551615}, allocator_ = 0x7f176c242c90, len_ = 8, buf_len_ = 9,
    rep_ = 0xfb74f0 "text_ack", release_ = true, static NULL_String_ = 0 '\0'}
    (gdb) print i
    $8 = 4294967295
    (gdb) print i+1
    $9 = 0

     
  • Paul Fitzpatrick

    Hi Lorenzo,
    Thanks for the report. What OS are you using? There are two possible implementations of the String class, depending on how you configure cmake. It is usually an ACE string type, but can be made into a std::string by turning on the "USE_STL_STRING" flag. Have you turned that flag on? If not, the relevent documentation is for ACE_String_Base<char>.
    In any case, you are right, the unsigned int should be replaced with a type that is correct when std::string is used. I'll look into it. There are several instances of this elsewhere in the library.
    Paul

     
  • Lorenzo G

    Lorenzo G - 2009-10-29

    Paul, thanks for the prompt reply.
    Regarding your answer -- no, I did not set any of those flags explicitly (compiling YARP and ICUB following the wiki at the moment..). So you are right too, I got the wrong documentation.

    Glad to be useful anyways.

     
  • Paul Fitzpatrick

    I checked in some code that uses the right string type, this should be fixed now - thanks!
    Paul

     
  • Paul Fitzpatrick

    • assigned_to: nobody --> eshuy
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks