Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1240814

fp.bugs 3811 solaris (native) threads called via java return -1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.0
    • core-libs
    • sparc
    • solaris_2.5

      From: ###@###.### (Ken Shirriff)
      This does not look like form output to me.


      ----------
      X-Sun-Data-Type: text
      X-Sun-Data-Description: text
      X-Sun-Data-Name: text
      X-Sun-Charset: us-ascii
      X-Sun-Content-Lines: 50

      I'm encountering problems while trying to add a Java wrapper to existing
      code that uses Solaris 2.5 threads (not Java threads!). Apparently there's
      either some bad interaction between the java interpreter and threads or
      the libthread.so library is not getting loaded properly. I don't know
      if this is a bug or if I'm just doing something wrong. I'm using the
      JDK on a Sparcstation 20 running Solaris 2.5.
       
      To make this more concrete, I have a method foo that should start up a
      thread. If I compile it as a C program it works, but if I use it as a
      native method through Java, thr_create returns -1 for some reason.
       
      The code is:
      void *thread_handler(void *ptr) {
              thr_exit(0);
              return 0;
      }
       
      long Iface_foo(struct HIface *tthis) {
          if (thr_create (NULL, (size_t)0,thread_handler, 0, THR_BOUND, NULL)) {
              perror("thr_create");
          }
          return 0;
      }
       
      I compiled it into a dynamically loadable library with:
      cc -G Iface.o IfaceImp.o -lthread -o libiface.so
       
      This code should start a new thread that exits, but instead the thr_create
      call returns -1 and doesn't modify errno. (This is the same behavior as
      if I compile the code as a C program without the -lthread flag. Thus,
      I think it's some sort of linkage problem.)
       
      I also tried using System.loadLibrary("thread") to force libthread.so to
      be loaded, but it immediately died in libthread code:
      _dynamic_create() failed, errno = 22

      I've attached a tar file with the test program.

      In case you're interested, what I'm trying to do is add a Java frontend
      to control our Solaris MC cluster. (Solaris MC is a cluster operating system
      that we're developing in Sun Labs.) The various nodes in the cluster
      communicate with IDL, using an ORB that we've developed. I want to build
      Java programs that will communicate with the cluster, accessing our existing
      IDL framework through native methods, so the Java progams can control the
      cluster and gather statistics. Since our ORB/IDL framework uses Solaris 2.5
      threads, I need to find a way to use threads with Java in order to make this
      all work.
       
      Thanks for any help,
      Ken Shirriff ###@###.### http://www.cs.berkeley.edu/

            tlindholsunw Timothy Lindholm (Inactive)
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: