Results 1 to 2 of 2

Thread: libmysqlclient - started crashing 11.4

  1. #1
    Join Date
    Feb 2009
    Location
    Finland
    Posts
    211

    Default libmysqlclient - started crashing 11.4

    Hello all.

    Got a strange one and am baffled. I have a server that delivers updates to the network and uses MySQL as a backend database engine.

    Up until about a week ago, the server was working perfectly. However, it has started crashing when it tries to make the connection to the MySQL server.

    The crash is triggered by an assertion failure within malloc in libc. The message I get is
    Code:
    UpdServer: malloc.c:3091: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
    Stack trace from the core file shows;
    Code:
    #0  0xffffe430 in __kernel_vsyscall ()
    #1  0xb66878df in raise () from /lib/libc.so.6
    #2  0xb6689220 in abort () from /lib/libc.so.6
    #3  0xb66ca040 in __malloc_assert () from /lib/libc.so.6
    #4  0xb66cc0c8 in _int_malloc () from /lib/libc.so.6
    #5  0xb66ce59a in malloc () from /lib/libc.so.6
    #6  0xb76acf4c in my_once_alloc () from /usr/lib/libmysqlclient.so.16
    #7  0xb76ad39c in ?? () from /usr/lib/libmysqlclient.so.16
    #8  0xb76add3a in ?? () from /usr/lib/libmysqlclient.so.16
    #9  0xb76ae348 in get_charset_by_csname () from /usr/lib/libmysqlclient.so.16
    #10 0xb76ce840 in mysql_init_character_set () from /usr/lib/libmysqlclient.so.16
    #11 0xb76cf112 in mysql_real_connect () from /usr/lib/libmysqlclient.so.16
    #12 0x0804ac69 in OpenMysql (MyPid=5999, Server=0x804c373 "localhost", User=0x804c36b "****", 
        Password=0x804c361 "*****", Database=0x804c35a "Voodoo") at UpdServer.c:952
    #13 0x0804bd1c in ProcessConnection (Connection=0x8051d30) at UpdServer.c:697
    #14 0x0804c0d0 in main (argc=1, argv=0xbfb03d34) at UpdServer.c:58
    The version of libclientmysql I have installed is 5.1.57-0.3.1

    The actual memory in the box passes the bios memory check - no errors but could this be a problem with the hardware?

    Any clues gratefully received.

    Cheers - AK

  2. #2
    Join Date
    Feb 2009
    Location
    Finland
    Posts
    211

    Default Re: libmysqlclient - started crashing 11.4 - SOLVED

    Hello again.

    Turns out that the crash is related to my use of an obsolete call - gethostbyaddr()

    I built the library that has this code some years ago...

    I use the call to get the hostname of the new client. If the call actually can resolve a host name, I copy it into a control structure attached to the client connection. If the call cannot resolve, I copy the string "Unknown".

    The memory I allocate to the hostname comes from the string lengths of a resolved name or "Unkown". If the host is "Unknown", the crash does not occur.

    If I get a host name (hostent structure) I allocate based on the strlen of the hostname in that struct. Despite having exactly the right amount of memory allocated, somehow copying from the name in the hostent struct to the client's struct, the crash results when I subsequently try to connect to the MySQL DB.

    I changed the code to get the client hostname using getnameinfo() and all the problems went away and the server is back in action.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •