Boost - to_iso_extended_string - invalid pointer

Feb 15, 2012 at 10:14am
This line of code is giving me an 'invalid pointer'.
std::cout << to_iso_extended_string( end_date ) << std::endl;

The correct date is printed, but the 'End' print is never executed,
unless 'to_iso_extended' is commented out.

---------------
Relevent code:
1
2
3
4
5
6
7
8
9
date end_date = day_clock::local_day();

//Output the parts of the date - current date
date::ymd_type ymd = end_date.year_month_day();
std::cout << ymd.year << "-" << ymd.month << std::endl;

std::cout << to_iso_extended_string( end_date ) << std::endl;

std::cout << "End" << endl;

*** glibc detected ***
/home/gdmps/NetBeansProjects/SymbolHistory/dist/Debug/GNU-Linux-x86/symbolhistory: free(): invalid pointer: 0x0945e2b8 ***
Feb 15, 2012 at 2:28pm
What is symbolhistory and how is free() called? I ran your code and it works for me.
Feb 15, 2012 at 4:41pm
symbolhistory is the executable from compiling, which it does sucessfully.

the statment does produce the correct date, but seem like it is bombing out when returning from the function
and trying to free mem the function it'self had grabbed.

traced out calls in boost, no free() that I could find.

Last edited on Feb 15, 2012 at 5:18pm
Feb 15, 2012 at 5:21pm
I just looked through all of boost::calendar and boost::to_iso_extended_string, I also stepped through construction deconstruction of both, didn't see any function called free() being called. Have you stepped through to see what is going on and to see where the call site for free() is?

Is there any other code you can post that may shed some light?

If you are certain it is happening where it is happening, catch the exception and see what it can tell you about it.
Feb 15, 2012 at 5:37pm
I will do that right now. Just have to figure out how.

Looking back thru the run, here is something that might help:

b7624000-b7632000 r-xp 00000000 08:01 201938
/usr/boost_1_48_0/stage/lib/libboost_date_time.so.1.4RUN FAILED (exit value 1, total time: 112ms)8.0

What I am unsure about is if the 'RUN FAILED' really points to libboost_date_time.so, or if there was just not a crlf put there.
I tend to think it does have meaning for the error, as everything I do to find some other statement causing it does not correct the problem. Only commenting out the one statement the program run without error.
Dont forget tho, that it does print out the date and then throws the error.

After 30 years of programming in C and a lapse of 10 years, I am having a hard time picking back up. Everything seems to have changed.

I am adding the last bit of code that I had not included before, but even with it commented out does not solve the problem becuase of the to_iso_extended... rest is just killing mysql connections before exit.

I have gone with an example right out of the 'book' and still get the error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
date end_date = day_clock::local_day(); // just use current date for test

//Output the parts of the date - current date 
date::ymd_type ymd = end_date.year_month_day();
std::cout << ymd.year << "-" << ymd.month << std::endl;
std::cout << "End" << endl;

std::cout << to_iso_extended_string( end_date ) << std::endl; - Does not work
std::cout << "End" << endl;

//std::string table_date;
//table_date = to_iso_extended_string( end_date );
//cout << "table_date: " << table_date << endl;

/*
while( true )
{
	stmt->execute( "CREATE TABLE " + table_date + " ( date varchar(15), symbol varchar(10), close varchar(20), adj_close  varchar(20), volume int(20), market_type varchar(20), active_feed varchar(20) )" );
	work_date = work_date + single;
	if( work_date > end_date ) break;
	table_date = to_simple_string( work_date );
}
*/      
        
    }

    delete stmt;
    delete con;
    return 0;
}

Last edited on Feb 15, 2012 at 5:43pm
Feb 15, 2012 at 5:44pm
Did you build the boost lib yourself or just link to it?
Feb 15, 2012 at 6:05pm
Built it.

But did I do it right, unsure. Mostly about the part where it stated I had to compile seperate ones.
I have to go back and look at directions and see if i missed something.

"A few libraries have optional separately-compiled binaries:"
"Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland."

I guess that must not have gotten compiled when I did the build.
Thought for sure I saw DateTime scoll across screen during build.
----------------
I seem to remmeber something about not mixing 'libstdc++.so.5.0.7' and '/libstdc++.so.6.0.13'.
According to the run printed out, the program/libraries are using mixed.
Do not know which function calls are using which lib.

--------------------

Went back and checked date/time of boost files. Downloaded on 2/13/2012, compiled boost on 2/14/2012 - which included all so's. So I did compile them all of them.
Last edited on Feb 15, 2012 at 6:47pm
Feb 16, 2012 at 12:11am
Found it, but really don't know what to do about it. I guess see if I can build it.
It puts out the free() error if it has been linked to 'libmysqlcppconn.so.5'

This is the connector file name: mysql-connector-c++-1.1.0-linux-glibc2.3-x86-32bit

The error:
*** glibc detected *** /home/gdmps/NetBeansProjects/SymbolHistory/dist/Debug/GNU-Linux-x86/symbolhistory: free(): invalid pointer: 0x099ce288 ***

-----------------
So why is it giving an error only when executing 'to_iso_extended_string'?

It's a bug: http://bugs.mysql.com/bug.php?id=64380

Last edited on Feb 23, 2012 at 3:12am
Topic archived. No new replies allowed.