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

Segmentation fault and core dump during test run on 5.3 (not 5.4)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0.2
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      ls
      On SunOS draven 5.4 generic sun4m sparc this code works fine, but on
      SunOS tachyon 5.3 Generic sun4d sparc it produces the error below.

       code:

      ****
      class thtest15_beta {

         public static void main(String args[]) {
           prime pf1 = new prime(100);
           boolean isok = false;

           isok = pf1.findprime();

           prime pf2 = new prime(500);
           prime pf3 = new prime(1000);
           prime pf4 = new prime(10000);

           isok = isok && pf2.findprime();
           isok = isok && pf3.findprime();
           isok = isok && pf4.findprime();

           if ( isok )
            System.out.println("the test pass is ok");
           else
            System.out.println("the test pass failed");
         }
      }

      class prime {
            int max_number = 1000;
             boolean traceflag = false;

            prime(int max)
            {
               traceflag = false;
               max_number = max;
            }

            prime(int max, boolean traceflag)
            {
                max_number = max;
                traceflag = traceflag;
            }

            public boolean findprime()
            {
              Pipe output = new Pipe( "Buffer0");

              int n = 3;
            

              Thread.currentThread().setName("Thread0");
              PrimeThread p = new PrimeThread(output, 3);
              p.setName("Thread1");
             
              if ( traceflag ) {
                output.setdebug();
                p.setdebug();
               }

              p.start();

              Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
              while(n < max_number ) {
               output.push(n);
               n += 2;
              }
              output.setDone();
              p.join();
              //System.out.println(Thread.currentThread().getName() + " Done");
              return true;
            }
      }

      class PrimeThread extends Thread {
         Pipe input, output = null;
         int factor;
         static int count = 2; // count for number of threads created, also for naming threads.
         private boolean debug = false;
         private PrimeThread child = null;

         PrimeThread(Pipe in, int fac) {
            input = in;
            factor = fac;
            child = null;
         }

         public void setdebug() { debug = true; }

         public void run() {
            int n;

            if ( debug )
               System.out.println(getName() + ": factor = " + factor);

            while( true) {
               n = input.pop();

            //if sender stops pushing and the buffer is empty, just stop popping
              if ( n == 0 ) {
               if ( output != null ) output.setDone();
               
                // wait for death of child thread if any
              if ( child != null ) child.join();
               //System.out.println(getName() + " Done");
               return;
              }

              if ( n % factor != 0 ) {
               if (output == null ) {
                  //System.out.println(n);
                  output = new Pipe("Buffer" + count);
                  PrimeThread p = new PrimeThread(output, n);
                  child = p;
              if ( debug )
              System.out.println(getName() + " created " + p.getName() + " with input buffer " + output.getbufname());
              p.setName("Thread" + count);
              count++;
              output.push(n);

              int new_pri = getPriority() - 1;
              if ( new_pri < Thread.MIN_PRIORITY )
                new_pri = Thread.MAX_PRIORITY;

               if ( debug ) {
                  output.setdebug();
                  p.setdebug();
               }

              p.setPriority( new_pri );
              p.start();

               } else
                  output.push(n);

              }
            }
         }
      }

      class Pipe {
         int buffer[];
         int head = 0, tail = 0;
         private boolean done = false;
         String bufname;
         private boolean debug = false;
         private final int bufsz = 16;
         private int pop_waitcount = 0;
         private int push_waitcount = 0;

         Pipe(String name)
         {
           bufname = name;
           done = false;
           head = 0;
           tail = 0;
           buffer = new int[bufsz];
           for(int i = 0; i < bufsz; i++ )
               buffer[i] = 0;
           pop_waitcount = 0;
           push_waitcount = 0;
         }

         public void setdebug()
         {
            debug = true;
         }

         public String getbufname()
         { return bufname; }

         public void printbuffer()
         {

         System.out.println(Thread.currentThread().getName() + " : " + bufname);
         System.out.println("head = " + head + " tail = " + tail );
          for(int i = 0; i < bufsz; i++ )
           System.out.print("--");
           System.out.print("\\n");

          for(int i = 0; i < bufsz; i++ )
           System.out.print("|" + buffer[i]);
          System.out.println("|");

          for(int i = 0; i < bufsz; i++ )
           System.out.print("--");
           System.out.print("\\n");
          
          System.out.println("\\n");
        }

         public synchronized void setDone()
          {
            done = true;
            // in case some guys are still doing pop()
           // if ( pop_waitcount > 0 ) notifyAll();
           notifyAll();
          }

         public synchronized void push(int item) {
            while((head+1) % buffer.length == tail) {
               if ( debug ) System.out.println(Thread.currentThread().getName() + ": "+ bufname + ".push(" + item + "), wait...");
              push_waitcount++;
              wait();
            }

            push_waitcount--;

            buffer[head] = item;

            head = (head+1) % buffer.length;

            if ( debug ) System.out.println(Thread.currentThread().getName() + " push(): n= " + item);

            // if ( push_waitcount > 0 ) notifyAll();

            if ( debug ) printbuffer();
           notifyAll();
         }

         // if the pipe is empty and the sender will push something
         // into the pipe, then we just wait.
         // if the pipe is empty and the sender will not push anything
         // into the pipe, then we just give up fetching, not wait silly
         // under the tree for a never-showup rabbit.
         public synchronized int pop() {
            int item;

            while(head == tail && !done) {
              if ( debug ) System.out.println(Thread.currentThread().getName() + ": "+ bufname + ".pop(), wait...");
             pop_waitcount++;
             wait();
            }

             pop_waitcount--;

            //if sender stops pushing and the buffer is empty, just return 0
            if ( head == tail && done ) {
              // to do extra notifyAll() is troublesome
              //notifyAll();
              return 0;
            }

            item = buffer[tail];
            buffer[tail] = 0;
            tail = (tail+1) % buffer.length;
      // if ( pop_waitcount > 0 ) notifyAll();
              notifyAll();
        if ( debug ) System.out.println(Thread.currentThread().getName() + " pop(): n= " + item);

            if ( debug ) printbuffer();
            return item;
         }
      }

      Produces:

      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_ACCERR [addr: 0xde27dde8]

              stackbase=DFFFF5C4, stackpointer=DFFFE8E8

      Full thread dump:
          "Finalizer thread" (TID:0xde90f358, sys_thread_t:0xde525de8) prio=1
          "Async Garbage Collector" (TID:0xde90f308, sys_thread_t:0xde547de8) prio=1
          "Idle thread" (TID:0xde90f290, sys_thread_t:0xde569de8) prio=0
          "clock handler" (TID:0xde90f098, sys_thread_t:0xde58bde8) prio=11
          "Thread0" (TID:0xde90f048, sys_thread_t:0x61168) prio=10 *current thread*
              prime.findprime(thtest15_beta.java:98)
              thtest15_beta.main(thtest15_beta.java:55)
      Monitor Cache Dump:
          PrimeThread@DE9108A0/DE948230 (key=0xde9108a0): monitor owner: "Thread0" unknown key (key=0xde547de8): unowned
              Waiting to be notified:
                  "Async Garbage Collector"
      Registered Monitor Dump:
          Finalize me queue lock: unowned
              Waiting to be notified:
                  "Finalizer thread"
          Thread queue lock: unowned
          Class lock: unowned
          Java stack lock: unowned
          Code rewrite lock: unowned
          Heap lock: unowned
          Has finalization queue lock: unowned
          Monitor IO lock: unowned
          Child death monitor: unowned
          Event monitor: unowned
          I/O monitor: unowned
          Alarm monitor: unowned
              Waiting to be notified:
                  "clock handler"
          Sbrk lock: unowned
          Monitor cache lock: unowned
          Monitor registry: monitor owner: "Thread0"
      Thread Alarm Q:
          sys_thread_t 0xde547de8 [Timeout in 809 ms]
      Segmentation Fault - core dumped
      core file created
      draven%

        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: