Like Tree1Likes
  • 1 Post By Elysia

Error detected : glibc

This is a discussion on Error detected : glibc within the C++ Programming forums, part of the General Programming Boards category; Hi people I have this error entering a function: (really the error lines are more than this I put) Code: ...

  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    33

    Error detected : glibc

    Hi people I have this error entering a function:
    (really the error lines are more than this I put)

    Code:
    *** glibc detected *** /home/elvio/workspace/aws/Debug/aws: double free or corruption (!prev): 0x0000000001eff100 ***
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f950c739b96]
    /home/elvio/workspace/aws/Debug/aws[0x40afde]
    /home/elvio/workspace/aws/Debug/aws[0x40a940]
    /home/elvio/workspace/aws/Debug/aws[0x409f3b]
    /home/elvio/workspace/aws/Debug/aws(_ZNSt6vectorIdSaIdEED1Ev+0x42)[0x4097a0]
    /home/elvio/workspace/aws/Debug/aws[0x40b4c5]
    
    The function is : (I print Welcome to see in console I enter in the function)

    Code:
    void pre_filter_Computations(vector< vector<double> > radius,vector< vector<double> > theta,int cols,int rows){
    
      vector<double>x(cols);
      vector<double>y(rows);
      vector< vector<double> >X(cols, vector<double>(rows));
      vector< vector<double> >Y(cols, vector<double>(rows));
      double epsilon = 0.0001;
    
      printf("welcome\n");
    
      for(int i=0;i<cols;i++){
          x[i]=((double)(i-cols)/2)/((double)cols/2);
      }
    
      for(int z=0;z<rows;z++){
           y[z]=-(((double)(z-rows)/2)/((double)rows/2));
       }
    
    for(int m=0;m<cols;m++){
      for(int n=0;n<rows;n++){
    
           X[m][n]=x[m];
           Y[m][n]=y[n];
      }
    }
    
          for(int a=0;a<rows;a++){
                for(int b=0;b<cols;b++){
    
                     X[a][b] = pow(X[a][b],2);
                     Y[a][b] = pow(Y[a][b],2);
                     X[a][b] = X[a][b] + Y[a][b];
                      radius[a][b] = sqrt(X[a][b]);
    
              }
          }
    
          radius[rows/2][cols/2]=1;
    
          for(int a=0;a<rows;a++){
               for(int b=0;b<cols;b++){
                   radius [a][b]= radius[a][b] + epsilon;
                   theta[a][b] = atan2(Y[a][b],X[a][b])*180/PI;
               }
          }
    
    }
    

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    I do not have such an error compiling this function and running it in the test application.

    Could you post minimum compilable and runnable test that illustrates the problem?

    As a side note - you are passing radius and theta by value - how do you plan to get the result of calculation?
    Why do you pass col and row as parameters instead of requesting vector sizes for example from radius vector?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    Hi you have reason. I have to pass the pointer to the vector of vector. I just studied C and not studied C++,but worling with images I need to use it. I m trying to assign a pointer to radius and theta.
    In main:

    Code:
    vector< vector<double> >radius(rows, vector<double>(cols); // no problem
    
    double *radius_ptr = &radius.front(); //cannot convert vector<double>* to double*
    About the function I suppose the problem is when I have to create the meshgrid, I mean when there is the 2 for innested and I create X[m][n] and Y[m][n]. the first innested for.

    Whit meshgrid I mean to transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y.

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    So, do you have a question?

    Show your code where you are calling the function.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    The question is :

    1)how to invoke the pointer to the vector. Because in that code I write below it gives me the error I wrote as a comment.
    2)is it the meshgrid I explain right with vectors? (MAybe that's the error)-

    I invoke the function:

    Code:
    
    double *radius_ptr=&radius.front();
    double *theta_ptr=&theta.front(); //I have the error here
    pre_filter_Computations(&radius_ptr,&theta_ptr);// I have an error too
    Last edited by Elvio Esposito; 06-30-2013 at 01:43 PM.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,625
    Your function takes vectors. Why are you trying to pass pointer to pointers to elements to it?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    because I have to do this datas (radius,theta) conserve their values exiting the function. Googling I read I have to pass the pointers because era not dynamic. I m sorry but I just studied C and not C++ and in my project I must use a little of C++

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,625
    I don't understand what you are trying to point out.
    It's up to your function whether or not it will modify the data passed as arguments or not. Pass a const reference if you don't want it to modify the vectors, or a (non-const) reference otherwise.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    Maybe I don t talk very well Eglish. Sorry. I just have to modify in the function the vectors. So I need that when I go back to the main that my vectors have new data, because I changed it in this function. So I need to pass a pointer I suppose.

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,625
    You can pass by reference.

    Code:
    void foo(std::vector<T>& myvector)
    {
    	myvector.push_back(/*blah*/);
    }
    
    std::vector<T> myvec;
    foo(myvec);
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    So do I have just to pass the & operator to the function and create the vector in the main to obtain pass by reference? Don t I need to create a pointer too?

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,625
    Maybe you should actually read what references are and what they do.
    stahta01 likes this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    I adjust it. Thanks Elysia. But I have the glibc error to solve.

  14. #14
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Show your code (including how you call the function)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  15. #15
    Registered User
    Join Date
    Jun 2013
    Posts
    33
    MAIN:
    Code:
    vector< vector<double> >radius(rows, vector<double>(cols);
    vector< vector<double> >theta(rows,cols);
    Code:
    pre_filter_Computations(radius,theta,cols,rows);
    

    function:
    Code:
    void pre_filter_Computations(vector< vector<double> >& radius,vector< vector<double> >& theta,int cols,int rows){
    
     vector<double>x(cols);  vector<double>y(rows);
      vector< vector<double> >X(cols, vector<double>(rows));  
    vector< vector<double> >Y(cols, vector<double>(rows)); 
     double epsilon = 0.0001;
      printf("welcome\n"); 
    
     for(int i=0;i<cols;i++);{     
         x[i]=((double)(i-cols)/2)/((double)cols/2);  
    }  
    for(int z=0;z<rows;z++){ 
          y[z]=-(((double)(z-rows)/2)/((double)rows/2));  
     }
    
    for(int m=0;m<cols;m++){
      for(int n=0;n<rows;n++){   
        X[m][n]=x[m];      
        Y[m][n]=y[n];
      }
    }
          for(int a=0;a<rows;a++){    
            for(int b=0;b<cols;b++){         
            X[a][b] = pow(X[a][b],2);        
             Y[a][b] = pow(Y[a][b],2);        
             X[a][b] = X[a][b] + Y[a][b];    
            radius[a][b] = sqrt(X[a][b]);          
           }     
        }   
    
       radius[rows/2][cols/2]=1;     
    
       for(int a=0;a<rows;a++){        
          for(int b=0;b<cols;b++){     
              radius [a][b]= radius[a][b] + epsilon;       
              theta[a][b] = atan2(Y[a][b],X[a][b])*180/PI;         
           }      
     }
    }
    

    Last edited by Elvio Esposito; 06-30-2013 at 09:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GLIBC DETECTED error
    By programhelp in forum C++ Programming
    Replies: 1
    Last Post: 07-20-2010, 10:01 PM
  2. glibc detected: what can I do?
    By violatro in forum C Programming
    Replies: 11
    Last Post: 06-11-2010, 06:39 AM
  3. glibc detected - error
    By mr_m4x in forum C Programming
    Replies: 2
    Last Post: 03-15-2009, 10:29 AM
  4. Replies: 3
    Last Post: 08-22-2008, 11:12 AM
  5. Replies: 7
    Last Post: 11-26-2007, 12:11 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21