dbTalk Databases Forums  

Segmention fault with several connections

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Segmention fault with several connections in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Segmention fault with several connections - 06-02-2006 , 03:15 PM






Hi,

isn't it possible to create several
mysqlpp::Connections? Both of them use same db, host,
user. Code below doesn't work.

class A {
A() {
mysqlpp::Connection con;
con= mysqlpp::Connection::Connection(...);
}
};

class B {
B() {
mysqlpp::Connection con;
con= mysqlpp::Connection::Connection(...);
}
};

int main() {
A a;
B b;
return 0;
}

Using g++ 4.0.4
mysql++: Version: 2.0.7-2+b1 (Debian).

It doesn't matter if con are objects or pointers.

Best regards,
Tomas.


gdb trace-back:
#0 0x080498e9 in
mysqlpp::Connection::OptionInfo:perator= ()
#1 0x08049974 in std::__copy<false,
std::random_access_iterator_tag>::copy<std::_Deque _iterator<mysqlpp::Connection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> >
()
#2 0x08049a4c in
std::__copy_aux<std::_Deque_iterator<mysqlpp::Conn ection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#3 0x08049af0 in std::__copy_normal<false,
false>::copy_n<std::_Deque_iterator<mysqlpp::Conne ction::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#4 0x08049b9c in
std::copy<std::_Deque_iterator<mysqlpp::Connection ::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#5 0x0804c8ed in
std::deque<mysqlpp::Connection::OptionInfo,
std::allocator<mysqlpp::Connection::OptionInfo>
Quote:
:perator= ()
#6 0x0804ca5f in mysqlpp::Connection:perator= ()
#7 0x0804caf2 in A::A ()
#8 0x08048afb in main ()


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: Segmention fault with several connections - 06-03-2006 , 02:45 PM






------=_Part_22477_4758657.1149363889863
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

It would appear that the issue isn't so much multiple mysqlpp::Connections
coexisting, but an issue with the assignment operator. The stack trace you
provided indicates that your program isn't even getting to your declaration
of b. I tried running the code you provided with a few modifications to get
it to compile, and the code hung. However, by commenting out the two
assignment lines (con=3D ...) it ran and exited fine.

It appears to me that using an assignment operator on mysqlpp::Connection i=
s
a behavior which hasn't been accounted for. A few minutes of poking around
leads me to suspect that the issue is actually with Lockable (which is
inherited by Connection). In any case, I think the most expedient thing for
you to do is not use the =3Doperator. You should be able to supply whatever
arguments you need directly to the constructor.

-Drew


On 6/2/06, Tomas Fischer < tomas_fischer99 (AT) yahoo (DOT) de> wrote:
Quote:
Hi,

isn't it possible to create several
mysqlpp::Connections? Both of them use same db, host,
user. Code below doesn't work.

class A {
A() {
mysqlpp::Connection con;
con=3D mysqlpp::Connection::Connection(...);
}
};

class B {
B() {
mysqlpp::Connection con;
con=3D mysqlpp::Connection::Connection(...);
}
};

int main() {
A a;
B b;
return 0;
}

Using g++ 4.0.4
mysql++: Version: 2.0.7-2+b1 (Debian).

It doesn't matter if con are objects or pointers.

Best regards,
Tomas.


gdb trace-back:
#0 0x080498e9 in
mysqlpp::Connection::OptionInfo:perator=3D ()
#1 0x08049974 in std::__copy<false,

std::random_access_iterator_tag>::copy<std::_Deque _iterator<mysqlpp::Conn=
ection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*
()
#2 0x08049a4c in
std::__copy_aux<std::_Deque_iterator<mysqlpp::Conn ection::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#3 0x08049af0 in std::__copy_normal<false,
false>::copy_n<std::_Deque_iterator<mysqlpp::Conne ction::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#4 0x08049b9c in
std::copy<std::_Deque_iterator<mysqlpp::Connection ::OptionInfo,
mysqlpp::Connection::OptionInfo const&,
mysqlpp::Connection::OptionInfo const*>,
std::_Deque_iterator<mysqlpp::Connection::OptionIn fo,
mysqlpp::Connection::OptionInfo&,
mysqlpp::Connection::OptionInfo*> > ()
#5 0x0804c8ed in
std::deque<mysqlpp::Connection::OptionInfo,
std::allocator<mysqlpp::Connection::OptionInfo
:perator=3D ()
#6 0x0804ca5f in mysqlpp::Connection:perator=3D ()
#7 0x0804caf2 in A::A ()
#8 0x08048afb in main ()


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verf=FCgt =FCber einen herausragenden Sch=
utz
gegen Massenmails.
http://mail.yahoo.com

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=3Dghasatta@gmail=
..com


------=_Part_22477_4758657.1149363889863--


Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Segmention fault with several connections - 06-03-2006 , 04:48 PM



Hi,

now I using a singleton pointer and it seems to work.
But I don't understand following code:

struct A {
A() {
mysqlpp::Connection con(mysqlpp::use_exceptions);
}
};

int main() {
A a;
}

Again, a segmention fault occurs, why?
If I use con to connect to a database with
connect(...) it works.

Best regards,
Tomas

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Segmention fault with several connections - 06-26-2006 , 02:07 PM



Drew M. wrote:
Quote:
It would appear that the issue isn't so much multiple mysqlpp::Connections
coexisting, but an issue with the assignment operator.
Yes. The problem is that it doesn't exist.

With no defined assignment operator, you just get a bitwise copy, which
is not the right thing with Connection. You don't want a clone of the
existing connection down to the bit level, you want a new connection
with the same parameters. I've added such semantics to Connection.
This will appear in the next release of MySQL++.

Tomas, I hope you can find the time to play with the version of MySQL++
in the Subversion repository, to see if this works for you, before it
gets into a release version.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.