Page 1 of 2 1 2 LastLast
Results 1 to 15 of 18

Thread: Pb between C++ client and Java Server

  1. #1
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22

    Pb between C++ client and Java Server

    Hello,


    My server is in C++. It is on a Toshiba TX board (Ice can be ported onto a Toshiba TX board, which can be a good news for you !!)
    On the board, Linux Montavista is installed.

    My client is in Java on a Windows PC.

    I tried "Minimal" example . It works perfectly.

    But when I would like to improve the programms, I have some problems.

    The server is running. I execute the client. All is all right. The execution is good.
    The server is still running. But when I would like to execute the client an other time, the server goes down and I have this message :

    server: ../../../include/IceUtil/Mutex.h:299: IceUtil::Mutex::~Mutex(): Assertion `rc == 0' failed.
    Aborted

    I tried to modify some parts of the server and the client, but I get always this message after a second try....

    With Minimal example, I can execute as many time as I want the client, the server never goes down...

    What can I do ??

    Thank you for your help !
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Do you have a way to get a stack trace? That would help a lot toward finding the problem.

    Also, if you could post the complete code for client and server, we could have a look at what might be wrong.

    Cheers,

    Michi.

  3. #3
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    The client source :
    Code:
    import Demo.*;
    import java.util.*;
    
    public class Client {
    
    	public static void main(String []args) {
    
    		Random random = new Random ();
    		Transmit trans;
    		
    		String s = null;
    		
    		int status = 0;
    		Ice.Communicator ic = null;
    		try {
    		 	ic = Ice.Util.initialize (args);
    			Ice.ObjectPrx base = ic.stringToProxy("hello:tcp -p 10000 -h 156.189.89.125");
    			Demo.HelloPrx hello = Demo.HelloPrxHelper.checkedCast(base);
    			if (hello == null) throw new Error("Invalid proxy");
    			
    			hello.sayHello("Hello !!");			
    
    			for (int i = 0; i < 3; i++)  {
    				int a = random.nextInt();
    				double d1 = random.nextDouble()*10000;
    				double d2 = random.nextDouble()*10000;
    				double d3 = random.nextDouble()*10000;
    
    				trans = hello.setClass(a, d1, d2, d3);
    				System.out.println("a : " + trans.a);
    				System.out.println("arr0 : " + trans.arr[0]);
    				System.out.println("arr1 : " + trans.arr[1]);
    				System.out.println("arr2 : " + trans.arr[2]);
    				hello.sendClass(trans); //send to the server
    			}
    			
    		} catch (Ice.LocalException e) {
    			e.printStackTrace();
    			status = 1;
    		} catch (Exception e) {
    			System.out.println(e.getMessage());
    			status = 1;
    		}
    		if(ic != null) {
    		  try {
    		        ic.destroy();
    		  } catch (Exception e) {
    		        System.out.println(e.getMessage());
    			  status = 1;
    		   }
    		}
    	System.exit(status);
    	}  //main
    } // Client
    The server :

    Code:
    #include <HelloI.h>
    #include <Ice/Ice.h>
    
    using namespace std;
    
    
    int
    main(int argc, char* argv[])
    {
        int status = EXIT_SUCCESS;
        Ice::CommunicatorPtr communicator;
        cout << "Server ready ..." << endl;
    
        try
        {
    	communicator = Ice::initialize(argc, argv);
    	Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000");
    	adapter->add(new HelloI, Ice::stringToIdentity("hello"));
    	adapter->activate();
    	communicator->waitForShutdown();
        }
        catch(const Ice::Exception& ex)
        {
    	cerr << ex << endl;
    	status = EXIT_FAILURE;
        }
    
        if(communicator)
        {
    	try
    	{
    	    communicator->destroy();
    	}
    	catch(const Ice::Exception& ex)
    	{
    	    cerr << ex << endl;
    	    status = EXIT_FAILURE;
    	}
        }
    
        return status;
    }

    HelloI.cpp

    Code:
    #include <HelloI.h>
    #include <Ice/Ice.h>
    
    using namespace std;
    
    void HelloI::sayHello(const string& s, const Ice::Current&) 
    {
        cout << s << endl;
    }
    
    Demo::TransmitPtr HelloI::setClass(int a, double d1, double d2, double d3, const Ice::Current&) {
      array arr (3);
      arr[0] = d1;
      arr[1] = d2;
      arr[2] = d3;
      TransmitPtr trans = new Transmit(a,arr);
      
      cout << "in setClass..." << endl;
      cout << "a : "<< trans->a << endl; 
      cout << "arr 0 : "<< trans->arr[0] << endl; 
      cout << "arr 1 : "<< trans->arr[1] << endl; 
      cout << "arr 2 : "<< trans->arr[2] << endl; 
      
      return trans;
    }
    
    void HelloI::sendClass(const TransmitPtr& trans, const Ice::Current&) {
      array arr (3);
      int a = trans->a;
      for (int i = 0; i < 3; i++) arr[i] = trans->arr[i];
      TransmitPtr trans_new = new Transmit(a,arr);
    
      cout << "in sendClass..." << endl;
      cout << "a : "<< trans_new->a << endl; 
      cout << "arr 0 : "<< trans_new->arr[0] << endl; 
      cout << "arr 1 : "<< trans_new->arr[1] << endl; 
      cout << "arr 2 : "<< trans_new->arr[2] << endl; 
    
    }
    HelloI.h
    Code:
    #ifndef HELLO_I_H
    #define HELLO_I_H
    
    #include <Hello.h>
    
    using namespace std;
    using namespace Demo;
    
    class HelloI : public Demo::Hello
    {
    public:
    
        void sayHello(const string& s, const Ice::Current&);
        Demo::TransmitPtr setClass(int a, double d1, double d2, double d3, const Ice::Current&);
        void sendClass(const TransmitPtr& trans, const Ice::Current&);
    };
    
    #endif
    Hello.ice
    Code:
    #ifndef HELLO_ICE
    #define HELLO_ICE
    
    module Demo
    {
    sequence<double> array;
    
    class Transmit {
          int a;
          array arr;
    }
    
    interface Hello
    {
       void sayHello(string s);
       Transmit  setClass(int a, double d1, double d2, double d3);
       void sendClass(Transmit trams);
    };
    
    };
    
    #endif
    Could you tell me how to get a stack trace ?

    Thank you very much
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  4. #4
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    This is the stack trace :

    before 1st try :

    #0 0x00626978 in __pthread_sigsuspend (set=0x7fff78a8)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    #1 0x00626690 in __pthread_wait_for_restart_signal (self=0x10007ca0)
    at pthread.c:1145
    #2 0x00621144 in __pthread_cond_wait (cond=0x100cb70c, mutex=0x100cb718)
    at restart.h:34
    #3 0x00507e6c in waitImpl<IceUtil::RecMutex> (this=0x100cb70c,
    mutex=@0x100cb718) at Cond.h:203
    #4 0x00506468 in IceUtil::Monitor<IceUtil::RecMutex>::wait() const (
    this=0x100cb70c) at Monitor.h:152
    #5 0x00503d8c in IceInternal::ObjectAdapterFactory::waitForShutdown () (
    this=0x100cb6e8) at ObjectAdapterFactory.cpp:66
    #6 0x005d9ad4 in Ice::CommunicatorI::waitForShutdown() (this=0x100cae20)
    at CommunicatorI.cpp:119
    #7 0x0041cb70 in main (argc=1, argv=0x7fff7da4) at Server.cpp:29


    after 1st try :
    #0 0x00626978 in __pthread_sigsuspend (set=0x7fff78a8)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    #1 0x00626690 in __pthread_wait_for_restart_signal (self=0x10007ca0)
    at pthread.c:1145
    #2 0x00621144 in __pthread_cond_wait (cond=0x100cb70c, mutex=0x100cb718)
    at restart.h:34
    #3 0x00507e6c in waitImpl<IceUtil::RecMutex> (this=0x100cb70c,
    mutex=@0x100cb718) at Cond.h:203
    #4 0x00506468 in IceUtil::Monitor<IceUtil::RecMutex>::wait() const (
    this=0x100cb70c) at Monitor.h:152
    #5 0x00503d8c in IceInternal::ObjectAdapterFactory::waitForShutdown () (
    this=0x100cb6e8) at ObjectAdapterFactory.cpp:66
    #6 0x005d9ad4 in Ice::CommunicatorI::waitForShutdown() (this=0x100cae20)
    at CommunicatorI.cpp:119
    #7 0x0041cb70 in main (argc=1, argv=0x7fff7da4) at Server.cpp:29


    after 2nd try :

    #0 0x00626978 in __pthread_sigsuspend (set=0x7fff78a8)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    #1 0x00626690 in __pthread_wait_for_restart_signal (self=0x10007ca0)
    at pthread.c:1145
    #2 0x00621144 in __pthread_cond_wait (cond=0x100cb70c, mutex=0x100cb718)
    at restart.h:34
    #3 0x00507e6c in waitImpl<IceUtil::RecMutex> (this=0x100cb70c,
    mutex=@0x100cb718) at Cond.h:203
    #4 0x00506468 in IceUtil::Monitor<IceUtil::RecMutex>::wait() const (
    this=0x100cb70c) at Monitor.h:152
    #5 0x00503d8c in IceInternal::ObjectAdapterFactory::waitForShutdown () (
    this=0x100cb6e8) at ObjectAdapterFactory.cpp:66
    #6 0x005d9ad4 in Ice::CommunicatorI::waitForShutdown() (this=0x100cae20)
    at CommunicatorI.cpp:119
    #7 0x0041cb70 in main (argc=1, argv=0x7fff7da4) at Server.cpp:29


    I hope it can help you !!

    Thank you !
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  5. #5
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    Bonjour Arnaud,

    I can't see anything wrong with your code and the stack traces aren't very helpful. What would really help is to see the stack trace of the assert. You should be able to get it by running the server under the debugger. When the server crashes, gdb should notify you that the program terminated and it should allow you to get the stack trace of the assert (using the "where" gdb command.)

    Alternatively, you could enable core files (by running "ulimit -c unlimited" in the shell where you run the server) and then open with gdb the server with this core file with "gdb ./server core.<pid>" (after the server crashed).

    Cheers,
    Benoit.

  6. #6
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    Bonjour Benoit,

    So, I tryed the method you told me but I think I should have done it not correctly.

    I start the server. I got his pid.
    After, I open the server using : gdb server core."PID". I got this :

    gdb server core.439
    GNU gdb 5.2.1
    Copyright 2002 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "mipsel-hardhat-linux"...
    /root/intent/home/arnaud/Ice-3.0.1-ok/demo/Ice/minimal/minimal2/core.439: No suc
    h file or directory.

    I run the client

    When the server crashes I type "where" and I have this :

    No stack.

    What is bad in what I do ?

    Thank you !
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  7. #7
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    The file named core.<pid> is created only after the process abnormally terminated. Try something like the following instead:

    Code:
      $ ulimit -c unlimited
      $ ./server
      <wait for server to assert>
      $ ls core.*
      $ gdb ./server core.<pid>
    If no core files is created, it's possible that core files don't work on your box. In this case, I would try to run the server under the debugger, something like the following for example:

    Code:
      $ gdb ./server
      (gdb) run
      <wait for server to assert>
      (gdb) where
    Cheers,
    Benoit.

  8. #8
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    Merci !!

    I used the first method

    I got this :

    Program terminated with signal 6, Aborted.
    #0 0x006c1c04 in kill () at <stdin>:2
    2 <stdin>: No such file or directory.
    in <stdin>

    is it ok ?
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  9. #9
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    No, I'm afraid this doesn't say much. Can you try the second method instead (run the server under debugger)?

    Benoit.

  10. #10
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    second method :

    Starting program: /root/intent/home/arnaud/Ice-3.0.1-ok/demo/Ice/minimal/minimal
    2/server
    Server ready ...

    Program received signal SIG32, Real-time event 32.
    0x00626978 in __pthread_sigsuspend (set=0x7fff7678)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    53 ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c: No such file or
    directory.
    in ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
    Current language: auto; currently c
    (gdb) where
    #0 0x00626978 in __pthread_sigsuspend (set=0x7fff7678)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    #1 0x00626690 in __pthread_wait_for_restart_signal (self=0x10007ca0)
    at pthread.c:1145
    #2 0x006257e4 in __pthread_create_2_1 (thread=0x100cb940, attr=0x4,
    start_routine=0xffffffff, arg=0x100cb920) at restart.h:34
    #3 0x0061c7ac in IceUtil::Thread::start(unsigned) (this=0x100cb920,
    stackSize=0) at Thread.cpp:547
    #4 0x00477680 in ConnectionMonitor (this=0x100cb920, instance=@0x7fff7948,
    interval=60) at ConnectionMonitor.cpp:60
    #5 0x004ab58c in IceInternal::Instance::finishSetup(int&, char**) (
    this=0x100cb360, argc=@0x7fff7b40, argv=0x7fff7d74) at Instance.cpp:762
    #6 0x005dda00 in Ice::CommunicatorI::finishSetup(int&, char**) (
    this=0x100cb328, argc=@0x7fff7b40, argv=0x7fff7d74)
    at CommunicatorI.cpp:319
    #7 0x0049c3c0 in Ice::initializeWithPropertiesAndLogger(int&, char**, IceIntern
    al::Handle<Ice::Properties> const&, IceInternal::Handle<Ice::Logger> const&, int
    ) (argc=@0x7fff7b40, argv=0x7fff7d74, properties=@0x7fff7a48,
    logger=@0x7fff7a50, version=30001) at Initialize.cpp:198
    #8 0x0049bca4 in Ice::initialize(int&, char**, int) (argc=@0x7fff7b40,
    argv=0x7fff7d74, version=30001) at Initialize.cpp:154
    #9 0x0041c440 in main (argc=1, argv=0x7fff7d74) at Server.cpp:25
    (gdb)



    I hope it can help you this time !!!
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  11. #11
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    No, I'm afraid this still doesn't help but we're getting close The debugger for some reasons stopped when it got a SIG32 signal. You should try to disable the handling of this signal in the debugger:

    Code:
      $ gdb ./server
      (gdb) handle SIG32 nostop
      (gdb) run
      <the server should start and you should be able to run the client...>
      ...
      <make the server to crash>
      (gdb) where
    Benoit.

  12. #12
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    I got it :

    server: ../../../include/IceUtil/Mutex.h:299: IceUtil::Mutex::~Mutex(): Assertio
    n `rc == 0' failed.

    Program received signal SIGABRT, Aborted.
    0x00626978 in __pthread_sigsuspend (set=0x7fff7878)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    53 ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c: No such file or
    directory.
    in ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
    Current language: auto; currently c
    (gdb) where
    #0 0x00626978 in __pthread_sigsuspend (set=0x7fff7878)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:53
    #1 0x00626690 in __pthread_wait_for_restart_signal (self=0x10007ca0)
    at pthread.c:1145
    #2 0x00621144 in __pthread_cond_wait (cond=0x100cb84c, mutex=0x100cb858)
    at restart.h:34
    #3 0x00507e6c in waitImpl<IceUtil::RecMutex> (this=0x100cb84c,
    mutex=@0x100cb858) at Cond.h:203
    #4 0x00506468 in IceUtil::Monitor<IceUtil::RecMutex>::wait() const (
    this=0x100cb84c) at Monitor.h:152
    #5 0x00503d8c in IceInternal::ObjectAdapterFactory::waitForShutdown () (
    this=0x100cb828) at ObjectAdapterFactory.cpp:66
    #6 0x005d9ad4 in Ice::CommunicatorI::waitForShutdown() (this=0x100cb328)
    at CommunicatorI.cpp:119
    #7 0x0041cb70 in main (argc=1, argv=0x7fff7d74) at Server.cpp:29
    (gdb)
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  13. #13
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    I'm afraid your debugger doesn't seem to support threads, it shows the main thread trace instead of showing the trace of the thread responsible for the assert. Does it load the pthread library when you execute the program? If shared library loading is disabled, here's one last thing you could try:

    Code:
      $ gdb ./server
      (gdb) set auto-solib-add 1
      (gdb) handle SIG32 nostop
      (gdb) run
      <the server should start and you should be able to run the client...>
      ...
      <make the server to crash>
      (gdb) where
    Hopefully, it will show the trace of the thread where the assert occured. If it doesn't, I would recommend to upgrade your debugger. You could also try to run your program on another Linux box with a recent distribution (we officially support Fedora Core 4) and see if you also get the crash and can get a better trace.

    Cheers,
    Benoit.

  14. #14
    arnaud is offline Registered User
    Join Date
    Feb 2006
    Location
    Bordeaux
    Posts
    22
    I tried this new method.

    I have the same trace as the last one.

    I thank you for your help!!

    Merci beaucoup !
    -----------------
    Arnaud

    ENSEIRB Student
    Bordeaux

  15. #15
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    I suspect something's wrong with the threading library of your Montavista distribution. The best way to figure it out is to check if your server works with a recent Linux distribution.

    Also, you should make sure you have the latest patches installed for your Montavista distribution.

    Cheers,
    Benoit.

Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Accessing a Java Server from a C# Client
    By ragavan.raman in forum Help Center
    Replies: 1
    Last Post: 09-15-2010, 09:15 AM
  2. Replies: 5
    Last Post: 02-05-2007, 05:17 AM
  3. Replies: 15
    Last Post: 07-29-2005, 10:18 PM
  4. Replies: 1
    Last Post: 05-09-2005, 08:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •