Hey all,
I've got a question...
The company I work for is a Supply Chain software company and we have some old legacy code that is creating core dumps. Now I've used GDB to look at the core dump and find where in the core dump it is occuring. Here is the important part:
Here is the function where the core dump seems to be rooted:Code:#0 0x60000000ca9f0560:0 in sFreePckMovPath (PckMovPaths=0x27272020) at varAllocInv.c:9768 9768 while (PckMovPaths->prev) (gdb) bt #0 0x60000000ca9f0560:0 in sFreePckMovPath (PckMovPaths=0x27272020) at varAllocInv.c:9768 #1 0x60000000ca9bbc70:0 in vartrnFreePickList (List=0x403b58d0) at varAllocInv.c:9846 #2 0x60000000ca9f47d0:0 in vartrnAllocateInventory ( pcktyp_i=0x40654700 "TOPOFF-REPLEN", prtnum_i=0x40e2c090 "64871", prt_client_id_i=0x40e22f10 "MDC", pckqty_i=400, orgcod_i=0x40e8e690 "----", revlvl_i=0x40e2a190 "----", lotnum_i=0x40e81ab0 "----", invsts_i=0x40d44270 "A", invsts_prg_i=0x7c6ec369 "", schbat_i=0x0, ship_id_i=0x0, ship_line_id_i=0x0, wkonum_i=0x0, wkorev_i=0x0, wkolin_i=0x0, carcod_i=0x0, srvlvl_i=0x0, client_id_i=0x0, ordnum_i=0x0, stcust_i=0x0, rtcust_i=0x0, ordlin_i=0x0, ordsln_i=0x0, concod_i=0x0, segqty_i=0x40e2df10 "400", stoloc_i=0x40a43920 "", lodnum_i=0x0, subnum_i=0x0, dstare_i=0x40e2dd30 "", dstloc_i=0x40e2a790 "FA31", Picks=0x7fff9090, srcare_i=0x40e97af0 "", pcklvl_i=0x40e2a6f0 "", pcksts_i=0x0, splflg_i=1, ovralcflg_i=0x0, untcas_i=5, untpak_i=1, untpal_i=0, min_shelf_hrs_i=-1, frsflg_i=0, frsdte_i=0x7fff90a0 "", trace_suffix_i=0x0, pipcod_i=0x40e8f090 "N", skip_invlkp_i=0, alloc_loc_flg_i=0, wrkzon_i=0x0, wrkzon_req_i=0, aisle_id_i=0x0, aisle_req_i=0, work_area_i=0x0, work_area_req_i=0) at varAllocInv.c:10703
Where PICK_MOVS is a typedef that is a structure. I had couple of questions about this:Code:static void sFreePckMovPath(PICK_MOVS * PckMovPaths) { PICK_MOVS *pckmovs; PICK_MOV *mov; if (!PckMovPaths) return; /* Go To Top of List */ while (PckMovPaths->prev) PckMovPaths = PckMovPaths->prev; while (PckMovPaths) { pckmovs = PckMovPaths; if (pckmovs->pckMovPath) { while (pckmovs->pckMovPath) { mov = pckmovs->pckMovPath; pckmovs->pckMovPath = mov->next; free(mov); } } PckMovPaths = pckmovs->next; free(pckmovs); } return; }
1) Since the last thing the core dump shows is "while (PckMovPaths->prev)" does that mean it's actually core dumping on that line of code? Or somewhere after that?
2) This file is 11,433 lines long and this pointer is being passed ALL OVER the place in here. As I said, it's not my code it's some old legacy stuff that is still in use. So, my suspision is that the pointer may have already been freed but was not set to NULL because the above function gets called like this:
Is there anyway to check if a pointer has already been freed? I've never heard of such a test? Or does anyone have any suggestions to help me start digging through this massive code to find a memory issue?Code:if (PickFoundList) { sFreePckMovPath(PickFoundList); PickFoundList = NULL; }