c++ - push_back causing sgfault -


I have a class arbad, which is created by me, which is basically for

A cover is the part of the square for this problem

  class arbad double {private: mpfr_t value; Public: Clear arbitrary (long double value_, unsigned long precision) {mpfr_init2 (value, exact); Mpfr_set_d (value, value_, MPFR_RNDN); } Explicit ArbDouble (long int value_, unsigned long precision) {mpfr_init2 (value, exact); Mpfr_set_ui (value, value_, MPFR_RNDN); } ArbDouble () {mpfr_init (value); } ArbDouble (unsigned long precision) {mpfr_init2 (value, exact); } Arbudal (Constable Arbud and others) {mpfr_init2 (value, other. Japreson ()); Mpfr_set (value, other value, MPFR_RNDN); } ArbDouble (const mpfr_t and others) {mpfr_init2 (value, mpfr_get_prec (other)); Mpfr_set (value, other, MPFR_RNDN); } Clear arbitrary (four * other, unsigned long-term precision) {mpfr_init2 (value, exact); Mpfr_set_str (value, other, 10, MPFR_RNDN); } ~ Arbabal () {mpfr_clear (value); } Inline unsigned long mill proposition () const {return mpfr_get_prec (value); } Inline arbor double & amp; Operator = (Constant Arbud and others) {mpfr_set_prec (value, other .getPrecision ()); Mpfr_set (value, other value, MPFR_RNDN); Return * This; }}   

Now, I am using std :: vector to store the matrix of these values. E.g.

  std :: vector & lt; ArbDouble & gt; Temporary; Temp.push_back (arc double ((long interval) 0, 64)); // Calling "Arbudal (long int value_, unsigned long-range precision)" std :: vector & lt; Std :: vector & lt; ArbDouble & gt; & Gt; CurrentOrbit; CurrentOrbit.push_back (temporary);   

And this causes a segfault on the Linux machine, but not on the Mac machine.

The error given by gdb is:

  Program received signal SIGSEGV, Segmentation error 0x00000000004069fefe :: Vector & lt; Std :: vector & lt; ArbDouble, std :: allocator & lt; ArbDouble & gt; & Gt ;, std :: allocator & lt; Std :: vector & lt; ArbDouble, std :: allocator & lt; ArbDouble & gt; & Gt; & Gt; & Gt; :: push_back (this = 0xb5daafcc938b13f6, __x = std :: vector length1, capacity1 = {...}) /usr/include/c++/4.5/bits/stl_vector.h:743 743 if (this -> gt; ; _M_impl._M_finish! = This-> _M_impl._M_END_of_storage) Does anyone know where the problem can be? I am not a very good class designer, so my guess is that there is a flaw in it. Any suggestions this is very welcome!   

This is a typical case of stack / heap corruption. You probably have an array where you are writing but outside of its boundaries, by doing this, you are changing the variable surrounding objects (in this case vector ) and Therefore there are strange errors on the internal of some other libraries (in this case std ).

Because all your classes call this mpfr_ set of tasks, most likely the error (unless some other code is shown). You can try debugging and find this problem anyway, but perhaps the easiest way to use it:

  valgrind --leak-check = full. / Your_program --args - - Your own program    

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -