[patch] Re: Reason && workaround for cflowds (others?) core dump.

From: Nicholas L. Nigay (nnigay@cboss.ru)
Date: Thu Nov 22 2001 - 06:16:24 PST

  • Next message: Shawn Armstrong: "Flowwatch dstaddr wildcard masking"

    Hello!.

    The problem seems to be more serious that i've expected.
    There are many uintXX_t variables that would be syslog()ed
    with the same format string, causing core dumps on some
    platforms ( i.e. %u for uint64_t on 32-bit hosts ).
    while acceptable for other ones ( %u for uint64_t on 64-bit host ).

    In order to avoid contructions like
    #if ( SIZE_OF ... == xx )
         syslog( with_ONE_format_string_ )
    #ilif ( SIZE_OF ... == YY )
          syslog( with_ANOTHER_format_string )
    #endif

    One could use explicit type conversion like this.
    ...
    char
            qwe[]="abcdefg";
    uint64_t
    asd;

    printf( "%llu %s\n", (unsigned long long)asd, qwe );
    ....

    The example above should work fine on both 32- and 64-bit platforms.
    I'm not sure about amount of performance loss.

    Attachment inside is patch against cflowd-2-1-b1.

    There are also a few errors with __FILE__,__LINE__
    that breaks format string sequence. such errors also fixed.

    Kevin Stewart wrote:

    > I think you will find the same issue in
    >
    > ./cflowd-2-1-a9/classes/include/CflowdUint64TrafficCounter.hh
    > inline int write(int fd) const
    > {
    > .
    > .
    > .
    > if (rc < (int)sizeof(this->_bytes)) {
    > syslog(LOG_ERR,
    > "[E] ArtsPrimitive.WriteUint64(%d,%d,%d) failed: %m {%s:%d}",
    > fd,this->_bytes,sizeof(this->_bytes),__FILE__,__LINE__);
    > return(-1);
    > }
    >
    > I just commented out both syslog calls after looking at my core dumps
    > it seems a lot more stable after that
    >
    > Kev
    >

    -- 
    Good luck!
    Nicholas L. Nigay
    


    --
    cflowd mailing list
    cflowd@caida.org
    



    This archive was generated by hypermail 2b29 : Thu Nov 22 2001 - 06:33:09 PST