tcpdump mailing list archives
Re: *** glibc detected *** corrupted
From: Guy Morand <Morand () telecontrol ch>
Date: Mon, 23 May 2011 12:12:38 +0200
-----Original Message----- From: tcpdump-workers-owner () lists tcpdump org [mailto:tcpdump-workers- owner () lists tcpdump org] On Behalf Of harish badrinath Sent: vendredi 20 mai 2011 19:33 To: tcpdump-workers () lists tcpdump org Subject: Re: [tcpdump-workers] *** glibc detected *** corrupted double-linked list The heap is being corrupted whn running on PPC. Do you have GDB on the embedded box??. I also sent a similar mail (infact i termed it: A possible bug in libpcap xD), turns out it was completely my fault. If you cant cross compile valgrind, then try using something like efence (http://en.wikipedia.org/wiki/Electric_Fence).
Hi, Thanks for your help and your precious advices! I tried that wonderful efence tool and it didn't detect anything ... Using GDB server was not much helpful ... However, I have the feeling that my "pcap thread" never leaves his loop this is why I think the problem is more from the pcap library and not from pthread or standard C library (or maybe indirectly) ... Maybe some more information is needed! I'm trying to write a "pcap thread manager" here is the "killProcess" where I break the pcap loop. I store every pcap information in a linked list. //--------------------- C CODE START ------------------ typedef struct pcapProcess{ int processId; char* type; pcap_t* handle; char* filter; pthread_t theThread; struct pcapProcess* next; }pcapProcess_t; void killPcapProcess(const char* arg) { pcapProcess_t* iterator = 0; int processId = 0; pcapProcess_t* prev = 0; pcapProcess_t* processToKill = 0; void* somethingForPthreadJoin = 0; char processIDChar[PROCESS_ID_MAX_CHAR_LENGTH]; if(arg == 0) { printString("Pleas enter a process ID to kill!\n"); return; } else processId = atoi(arg); pthread_mutex_lock(&mutexProcessList); // <----- Start critical iterator = processListHead; while(iterator != 0) { if(processId == 0 || iterator->processId == processId) { // Take process out of the list processToKill = iterator; if(prev != 0) prev->next = iterator->next; else processListHead = iterator->next; iterator = iterator->next; // Kill process ... sprintf(processIDChar, "%i", processToKill->processId); printString("Breaking loop for thread "); printString(processIDChar); printString(" ...\n"); pcap_breakloop(processToKill->handle); pcap_close(processToKill->handle); printString("Loop broken, joining thread ...\n"); // Join the thread /********************************* HERE THE JOIN IS BLOCKING BECAUSE THE THREAD NEVER LEAVES PCAP_LOOP ***************************************************/ if(pthread_join(processToKill->theThread, &somethingForPthreadJoin) != 0) { printString("Couldn't join process "); printString(processIDChar); printString("\n"); } else { printString("Process "); printString(processIDChar); printString(" killed\n"); } // Clean memory if(processToKill->filter != 0) free(processToKill->filter); free(processToKill->type); free(processToKill); // Stop job if need to kill only one process if(processId != 0) { pthread_mutex_unlock(&mutexProcessList); // <----- End critical return; } } else { prev = iterator; iterator = iterator->next; } } pthread_mutex_unlock(&mutexProcessList); // <----- End critical if(processId != 0) printString("Process not found!\n"); } //--------------------- C CODE STOP ---------------- And where the pcap_loop is implemented ... //--------------------- C CODE START -------------------- void startPcapProcess(void* pcapProcess, void (*gotPacket)(u_char*, const struct pcap_pkthdr*, const u_char*)) { pcapProcess_t* iterator = 0; pcapProcess_t* pcapProcessInfo = (pcapProcess_t*)pcapProcess; char processID[PROCESS_ID_MAX_CHAR_LENGTH]; // Add process to process linked list ... pthread_mutex_lock(&mutexProcessList); // <----- Start critical iterator = processListHead; if(iterator == 0) processListHead = pcapProcessInfo; else { while(iterator->next != 0) iterator = iterator->next; iterator->next = pcapProcessInfo; } pthread_mutex_unlock(&mutexProcessList); // <----- End critical // Start process pcap_loop(pcapProcessInfo->handle, 0, gotPacket, pcapProcess); // Stopped printString("PCAP thread "); sprintf(processID, "%i", pcapProcessInfo->processId); printString(processID); printString(" left pcap_loop!\n"); } //--------------------- C CODE STOP ----------------- I know that the pcap process never leaves because of the console output. Here is what I got on my x86: /* The following comes from the pcap processes manager */ Killing pcap processes ... Breaking loop for thread 1 ... Loop broken, joining thread ... /* The following comes from the pcap thread */ PCAP thread 1 left pcap_loop! /* The following comes from the pcap processes manager */ Process 1 killed And on my PPC platform /* The following comes from the pcap processes manager */ Killing pcap processes ... Breaking loop for thread 1 ... Loop broken, joining thread ... /* The following comes from the pcap thread */ !!!! ABSOLUTELY NOTHING !!!!! I expect at least the "PCAP thread 1 left pcap_loop!" message Thanks for your suggestions ! Guy - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Re: *** glibc detected *** corrupted double-linked list Guy Morand (May 20)
- Re: *** glibc detected *** corrupted rixed (May 20)
- Re: *** glibc detected *** corrupted Guy Morand (May 20)
- <Possible follow-ups>
- *** glibc detected *** corrupted double-linked list Guy Morand (May 20)
- Re: *** glibc detected *** corrupted double-linked list harish badrinath (May 20)
- Re: *** glibc detected *** corrupted Guy Morand (May 23)
- Re: *** glibc detected *** corrupted double-linked list harish badrinath (May 20)
- Re: *** glibc detected *** corrupted rixed (May 20)