473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error: glibc detected and Invalid pointer

hello all i have a code which looks fine when reviewed but when the application has a long run say for example of 2 days it gets exit, because of glibc error and the sample code is as follows:
Expand|Select|Wrap|Line Numbers
  1. while (1)
  2.          {
  3.  
  4.              if((kfp = kd_open(kd_filename, READ, NULL , INIT_YES))== NULL) {
  5.                  printf("%s: File not found ...\n", kd_filename);
  6.                  if (!forceflag) {
  7.                      sleep(5);
  8.                  }
  9.                  else {
  10.                      exit(0);
  11.                  }
  12.              }
  13.             else
  14.              {
  15.                  kd_fileid.capture_session_start_epoch_second = kfp->header.file_id.capture_session_start_epoch_second;
  16.                  kd_fileid.file_sequence_counter = kfp->header.file_id.file_sequence_counter;
  17.  if ( (kfp->header.file_type & END_FILE)== END_FILE )
  18.                      kd_end_flag = 1;
  19.                  else
  20.                      kd_end_flag = 0;
  21.  
  22.                  for(i=0;i<kfp->header.total_packet_count;i++)
  23.                  {
  24.                      if((err=kd_read_next_packet(kfp,(PACKET_t *)kd_row))>0)
  25.                      {
  26.                          pktCount++;
  27.                          pktlen = sizeof(PACKET_HEADER_t) + ((PACKET_t *)kd_row)->kph.kipd.ip_description_str        ing_len + ((PACKET_t *)kd_row)->kph.kipd.ip_packet_len ;
  28.                          send_packets_to_card(kd_row, pktlen);
  29.                      }
  30.                      else
  31.                      {
  32.                          printf("-->%d\n",((PACKET_t *)kd_row)->kph.kipd.ip_packet_len);
  33.                          printf("Error in  File:%d\n",err);
  34.                          break;
  35.                      }
  36.                  }
  37.                  kd_close(kfp, CAPTURE_END);
  38.  
  39.                  if (!forceflag) {
  40.                      if ( (kd_fileid.file_sequence_counter % max_kd_files_per_dir) == 0 ) {
  41.                          dircnt += 1;
  42.                      }
  43.                      kd_fileid.file_sequence_counter += 1;
  44.                      memset((void *)kd_filename, 0, 1024);
  45.                      memset((void *)dir_fname, 0, 512);
  46.                      getdfname(kd_fid, dircnt, kd_fileid.file_sequence_counter, dir_fname);
  47.                      getfilename(kbasedir, dir_fname, kd_filename);
  48.                  }
  49.                  if (kd_end_flag){
  50.                      memcpy(kd_row, FLUSH_SESSION_STR, sizeof(FLUSH_SESSION_STR));
  51.                      printf("Sending Flush sessions command to card\n");
  52.                      send_cntl_cmds_to_card(FLUSH_SESSIONS, FLUSH_SESSION_STR, sizeof(FLUSH_SESSION_STR));
  53.                      return 0;
  54.                  }
  55.              }
  56.              if (forceflag) {
  57.                  break;
  58.              }
  59.          }
  60.          free(kd_row);
  61.          return 0;
  62. }
when the kd_read_next_packet function returns it returns -2 indicating an error condition.Hence the message"Error in file:-2"gets printed and after this i get the message of *** glibc detected *** free(): invalid pointer: 0x0000000000515df0 ***
This will always be in infinite loop the pointer kfp is created on stack.Does the above error suggest that it is due to corruption of pointer kfp or kd_row.these two pointers do not have any problems they are malloced kfp returns a pointer to a file structure which is fine.
May 16 '07 #1
1 2897
AdrianH
1,251 Expert 1GB
Good luck with that. ;)

I've only looked at your code briefly, so I知 not going to comment on its correctness (might not be enough there anyway), however, if you wish to hire me, I値l look in to it further as I知 a contractor.

The problem may be coming from any number of places. In the code you are working on is only one of them (I知 assuming that this is part of a larger system of threads and/or interrupt handlers), but I知 not going to even look at this further without a contract and design schematics (if you have any).


Adrian
May 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: alex323 | last post by:
Hey. I must have an array that can be resized dynamically. I have coded an implementation of it using malloc/realloc, but I am getting a runtime error as seen below in GDB: *** glibc detected...
4
by: Stian Karlsen | last post by:
Hi. I'm getting an error in my program. It doesn't occur each time even if the same things happend in my program each time I run it. There will however be different values used for calculations in...
0
by: Darrell D. Mobley | last post by:
I am working on setting up a new server. It is running PHP v4.4.1, CentOS 4.3 i686 - WHM X v3.1.0, Cpanel WHM 10.8.0 cPanel 10.8.2-R83, MySQL 4.1.18-standard, Apache 1.3.34 (Unix), Kernel...
1
by: Gary Wessle | last post by:
Hello I am getting this run time error, no clue what to look for. any idea please? many thanks **************************************************************** *** glibc detected ***...
1
by: toutnom | last post by:
I can successfully compile the code give below. But at run time, I get some rrors (also given below). I have no clue, why I am getting these errors. Can somebody help. Thanks in advance. CODE...
36
by: gert | last post by:
Any comments why char **page doesn't reallocate #include <stdlib.h> void add(char **page,char *line,int n) { char **temp; if(temp=realloc(page,sizeof(char *)*(n+1))) {
3
by: Renzr | last post by:
I have a C++ package which works very well in the 32-bit Linux-like OS. However, it will lead to a "*** glibc detected *** ./ex2: munmap_chunk(): invalid pointer" in 64-bit (Fedora 7-64), when it...
0
by: John [H2O] | last post by:
Hello, I have a module created from a Fortran file to read in unformatted binary fortran output. It works fine for some datasets, but crashes with others. The strange thing is it will loop...
0
by: John [H2O] | last post by:
There's a lot of greek for me here ... should I post to numpy-discussions as well??? The backtrace is at the bottom.... Thanks! GNU gdb Fedora (6.8-21.fc9) Copyright (C) 2008 Free...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.