473,241 Members | 1,703 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,241 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.          {
  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;
  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);
  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 2882
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).

May 16 '07 #2

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

Similar topics

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...
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...
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...
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 ***...
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...
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))) {
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...
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...
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...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you値l learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.