Re: [Quickfix-developers] Seg fault in libc.so while working with quickfix from Java
Brought to you by:
orenmnero
From: Oren M. <ore...@ya...> - 2003-03-19 15:07:21
|
You need to attach the java process itself to the debugger. If you want to debug, you should compile the C++ and the Java code with the -g option. Then you can call "gdb java" and set your arguments to call banzai. You can only set breakpoints in quickfix_jni.so after it is loaded by System.loadLibrary. This is usually a pain, since it requires a rebuild of QuickFIX with the debug options. Inserting trace statements where the problem is occuring (SocketInitiator.cpp), may help you track the problem down quicker. --- David Monheit <Dav...@mo...> wrote: > Hi Gene, > > I have applied both your patches and rebuilt all. > Unfortunately, I still get > the core dump :-( I also made sure that the host > names (and tried ip addresses > as well) were sensisble. > > How does one debug a jni lib? By attaching to the > running java code with gdb? > > Thanks and regards > David > > Gene Gorokhovsky wrote: > > > This, as Sergey discovered the hard way, is what > > happens on Linux when the initiator's > > SocketConnectHost is invalid. The reason is that > > Quickfix Utility.cpp and SocketConnector.cpp > ignore > > bad return from gethostbyname. This is easily > > reproducible on Linux by changing > SocketConnectHost in > > cfg/tradeclient.cfg and banzai.cfg to something > > random. Both C++ and JNI client will fail with > > segfaults when session connect will be attempted. > > > > The chain of events is as follows: > > Invalid host name is specified in call to > > socket_createConnector > > socket_createConnector calls socket_hostname > > socket_hostname calls gethostbyname which returns > > NULL > > socket_hostname in turn returns NULL, which gets > > passes as an argument to inet_addr > > inet_addr calls inet_aton internally, which > crashes > > because its parameter is NULL instead of required > > pointer. > > > > Here is the two patches that fix this problem. > > > > Stylistically there is some code overlap between > > Utility.cpp and SocketConnector.cpp, which in the > best > > of worlds should be eliminated, but I prefer my > > patches to be minimally invasive. > > > > Gene > > --- Sergey Gribov <se...@se...> wrote: > > > Hello, > > > > > > We have the following problem while working from > > > Java: > > > at a start time the Java application which uses > the > > > quickfix > > > version 1.3.2 it fails with the following > exception: > > > > > > > > > An unexpected exception has been detected in > native > > > code outside the VM. > > > Unexpected Signal : 11 occurred at PC=0x40149C73 > > > Function=inet_aton+0x3F > > > Library=/lib/libc.so.6 > > > > > > Current Java thread: > > > at > > > org.quickfix.SocketInitiator.doStart(Native > Method) > > > at > > > org.quickfix.SocketInitiator.start(Unknown > Source) > > > ..... > > > > > > Anybody saw something like this? > > > Some other quickfix Java applications seems to > be > > > working fine... > > > > > > Any idea what can cause it? > > > > > > Thanks in advance, > > > > > > -- > > > > > > //========================================================================\\ > > > Sergey Gribov | A > > > specialist is someone who > > > E-Mail: se...@se... | learns > more > > > and more about less > > > WWW: http://www.sergey.com/ | and > less, > > > and ends up knowing > > > Phone: (617)7101683 | > everything > > > about nothing... > > > > > > \\========================================================================// > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by:Crypto > Challenge > > > is now open! > > > Get cracking and register here for some mind > > > boggling fun and > > > the chance of winning an Apple iPod: > > > > > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > > > _______________________________________________ > > > Quickfix-developers mailing list > > > Qui...@li... > > > > https://lists.sourceforge.net/lists/listinfo/quickfix-developers > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Platinum - Watch CBS' NCAA March Madness, > live on your desktop! > > http://platinum.yahoo.com > > > > > ------------------------------------------------------------------------ > > --- Utility.cpp Tue Mar 18 17:23:17 2003 > > +++ /home/geneg/tmp/Utility.cpp Thu Feb 20 > 00:34:31 2003 > > @@ -112,13 +112,9 @@ > > { > > int socket = ::socket( PF_INET, SOCK_STREAM, > IPPROTO_TCP ); > > - const char * num_dot_addr = socket_hostname( > address ); > > - if (num_dot_addr == 0) > > - return -1; > > > > sockaddr_in addr; > > addr.sin_family = PF_INET; > > addr.sin_port = htons( port ); > > - addr.sin_addr.s_addr = inet_addr(num_dot_addr); > > - > > + addr.sin_addr.s_addr = inet_addr( > socket_hostname( address ) ); > > > > int result = connect( socket, reinterpret_cast > < sockaddr* > ( &addr ), > > > > > ------------------------------------------------------------------------ > > --- SocketConnector.cpp Tue Mar 18 21:11:01 2003 > > +++ /home/geneg/tmp/SocketConnector.cpp Tue Mar 18 > 21:08:13 2003 > > @@ -107,12 +107,8 @@ > > int sock = socket( PF_INET, SOCK_STREAM, > IPPROTO_TCP ); > > > > - const char * num_dot_addr = socket_hostname( > address.c_str() ); > > - if (num_dot_addr == 0) > > - return 0; > > - > > sockaddr_in addr; > > addr.sin_family = PF_INET; > > addr.sin_port = htons( port ); > > - addr.sin_addr.s_addr = inet_addr(num_dot_addr > ); > > + addr.sin_addr.s_addr = inet_addr( > socket_hostname( address.c_str() ) ); > > > > int result = ::connect( sock, reinterpret_cast > < sockaddr* > ( &addr ), > > -- > NOTICE: If received in error, please destroy and > notify sender. Sender does not waive > confidentiality or privilege, and use is prohibited. > > > __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com |