Thread: double free or corruption (fasttop)

  1. #1
    Registered User
    Join Date
    Jan 2011

    Unhappy double free or corruption (fasttop)

    Hello, I've a problem with this kind of error that appears into the function below :
    void   conf_supprimer_config(
    Widget w,                    
    XtPointer   pst_client_data, 
    XtPointer   pst_call_data   
    /*Local variables   */
    int    *pi_position_list;        
    int     i_nbr_elements;          
    int    *pi_indice;               
    pi_indice = (int*)pst_client_data;
    pi_position_list = (int*)NULL;
    i_nbr_elements = 0;
    if ((*pi_indice != C_CONF_LISTE_STACNES) && (*pi_indice != C_CONF_LISTE_STAEXT))
       msg_ano (MACH, C_CONF_ERR_LOGICIEL, (long)250, (long)NULL, (long)NULL, (long)NULL, (long)NULL);
       goto fin;
    conf_i_indice = *pi_indice;
    XmListGetSelectedPos (conf_tw_config[conf_i_indice],
    if ( i_nbr_elements == 1 )
       x_aff_valid(C_CONF_MESS_SUPPRESION_FIC, conf_supprimer_fichier, 
    /* Free memory                                           */
    if ( pi_position_list != (int*)NULL)
       XtFree ((int*) pi_position_list);
    I supposed the error comes from XtFree but I don't understand the reason the error explains me and how to resolve the problem ...
    If someone knows ...

    Thx all !

  2. #2
    Registered User
    Join Date
    Jan 2011
    Just to add the whole state of the error :

    *** glibc detected *** ../bin/conf: double free or corruption (fasttop): 0x08966b20 ***
    ======= Backtrace: =========
    ======= Memory map: ========
    00101000-00117000 r-xp 00000000 fd:00 205261 /usr/lib/
    00117000-00118000 rwxp 00016000 fd:00 205261 /usr/lib/
    00119000-0011f000 r-xp 00000000 fd:00 227853 /usr/lib/
    0011f000-00120000 rwxp 00005000 fd:00 227853 /usr/lib/
    00120000-00122000 rwxp 00120000 00:00 0
    00122000-00261000 r-xp 00000000 fd:00 2689196 /lib/

  3. #3
    The Dragon Reborn
    Join Date
    Nov 2009
    Dublin, Ireland
    629 this C code?
    You ended that sentence with a preposition...Bastard!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Why isn't conf_supprimer_config() printed in the back trace?

    Is ../bin/conf your program? If so, compile it with -g (you should get function names resolved in the back trace).

    You can then use gdb to help you look around to try and find the problem.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jan 2011
    Yes, it is C code running with Linux RedHat 5.0
    The function is part of conf.c and that's why the /bin/conf refers to executable conf

    Anyway, I found the problem. This error is due to pi_position_list initialization (=(int*)NULL.
    I don't know why but it seems that this initialization is not needed and XtFree (X11 free memory function) try to free some already desallocated memory.

    So, by suppressing the initilialization line, it works.

    Another way to get rid of this kind of error is to write "export MALLOC_CHECK_=0" in command line, before running the program

    maybe these solutions might help others ...
    Thanx again

  6. #6
    Join Date
    Aug 2010
    Ontario Canada
    Quote Originally Posted by Eman View Post this C code?
    It appears to be, but the writer has a very unique formatting style.

  7. #7
    Registered User
    Join Date
    Nov 2010
    Long Beach, CA
    From GNU's website:

    If MALLOC_CHECK_ is set to 0, any detected heap corruption is silently ignored
    That scares the @#&$& out of me. You are doing something wrong and dangerous, so fix your problem instead of sweeping it under the rug. Not everybody who runs your program will have MALLOC_CHECK_=0 or want to set it every time they run it.

    Is XmListGetSelectedPos a function you wrote? That's where I would look for the actual cause of your problem, since that's the only thing that modifies pi_position_list in the code you posted. Does it do something different depending on whether the value in pi_position_list is NULL?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error in printf line,,,what's wrong?
    By mft_ika in forum C Programming
    Replies: 9
    Last Post: 03-19-2010, 08:46 PM
  2. double free or corruption (out)
    By Mouser58907 in forum C Programming
    Replies: 5
    Last Post: 02-25-2009, 12:20 AM
  3. Replies: 7
    Last Post: 11-26-2007, 01:11 PM
  4. Malloc - Free giving double free or corruption error
    By andrew.bolster in forum C Programming
    Replies: 2
    Last Post: 11-02-2007, 06:22 AM
  5. Help with multi function progam
    By WackoWolf in forum C Programming
    Replies: 22
    Last Post: 10-13-2005, 02:56 AM