![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| ||||||
| ||||||
|
|
I had problems earlier that seemed to be caused by dangling pointers, and the documentation wasn't very clear on which methods return copies of data and which return pointers, |
|
So a Result object has no pointers into the Query object then? |
|
But I have to keep the Result until I'm done with all Row and ColData objects, don't I? |
perator[] in the refman.|
#0 0x004c4da6 in __gnu_cxx::__mt_alloc<mysqlpp::mysql_type_info, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate (this=0x9c4c660, __n=2) at /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/ext/mt_allocator.h:719 #1 0x004c9626 in mysqlpp::ResUse::copy (this=0xbfc2ad50, other=@0xbfc2ae28) |
|
#0 0x0804fc40 in __gnu_cxx::__mt_alloc<std::string, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate (this=0xbf8ce54c, __n=15) at /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/ext/mt_allocator.h:719 #1 0x0804fcad in std::_Vector_base<std::string, std::allocator<std::string |
|
#0 0x0805106c in __gnu_cxx::__mt_alloc<std::string, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate (this=0xbffba8d8, __n=2) at /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/ext/mt_allocator.h:719 #1 0x080510d9 in std::_Vector_base<std::string, std::allocator<std::string |
#2
| |||
| |||
|
|
onsdagen den 17 augusti 2005 18:46 skrev Warren Young: Björn Persson wrote: I had problems earlier that seemed to be caused by dangling pointers, and the documentation wasn't very clear on which methods return copies of data and which return pointers, So send a patch. The documentation doesn't fix itself. I'm pretty sure you don't want any patches from me until I actually know something that isn't documented. :-) So a Result object has no pointers into the Query object then? A simple grep answers this question. (For the impatient, the answer is, "no".) But I have to keep the Result until I'm done with all Row and ColData objects, don't I? Probably not. For example, Result::at() plainly returns Rows by value. If you get a Row object, and are then done retrieving results, you can reuse the Result object. ColData objects, similarly, are returned by value from Row objects. Interesting. The question is then: What caused the problems I had earlier, and why did they go away when I stopped returning Results and Rows from functions? Maybe that was the same bug that's causing my current problem. In that case it's not a new bug in GCC 4 for example, as I had GCC 3.4 then. You're in a better position to debug this than I am...a live program yields more info than the backtrace of a dead one. Yes, but I lack the necessary experience. I was hoping someone who's familiar with the internals of MySQL++ would be able to help me find the problem, or that others would have the same problem and know more about it. But the fact that the program bombs while trying to do some kind of allocation suggests that the heap may already be scragged. You may be viewing secondary damage. That's very probable, especially with those alerts from GlibC taken into account. Try running your program under valgrind, or your favorite memory debugger. I'm afraid I don't have a favorite memory debugger as I've never used one. I've heard mentions of Valgrind. I'll see when I can find the time to try it. Björn Persson |
#3
| |||
| |||
|
|
I'm pretty sure you don't want any patches from me until I actually know something that isn't documented. :-) |
|
Interesting. The question is then: What caused the problems I had earlier, and why did they go away when I stopped returning Results and Rows from functions? |
|
You're in a better position to debug this than I am...a live program yields more info than the backtrace of a dead one. Yes, but I lack the necessary experience. |
#4
| |||
| |||
|
|
Here's a program that does just that – gets a Row and reuses the Result. Then it tries to use the Row object, but the expected data isn't there. |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
The problem is, that "names_" and "types_" are not neccessayrily initialized with "new". Since I changed the code like this: " *if* (names_) { *delete* names_; names_ = 0; } *if* (types_) { *delete* types_; types_ = 0; } |
#7
| |||
| |||
|
|
What compiler are you using? g++ 4.0.3 |
![]() |
| Thread Tools | |
| Display Modes | |
| |