Bug in initThreads() in thread.c

Wei Xiang WeiXiang at ubisoft.com.cn
Wed Sep 9 18:09:15 PDT 1998


Hi Kim,

Could you tell me where I can find Kaffe for VC++?  Thank you very much.

Sincerely yours,
Wei Xiang

> -----Original Message-----
> From:	Kim, Jongwon (freefish) [SMTP:freefish at cselab.snu.ac.kr]
> Sent:	Wednesday, September 09, 1998 2:41 PM
> To:	kaffe at transvirtual.com
> Subject:	Bug in initThreads() in thread.c
> 
> Hi,
> 
> In testing Kaffe for Visual C++, I got exception.
> The location of exception is add method in java.lang.ThreadGroup.java with
> JDK1.1.6.
> The exception occurred at calling createInitialThread("main") in thread.c.
> The instance variable, threads is not null and length is 0. 
> So I modified to following line.
> 
> unhand(standardGroup)->threads = 0; //
> (HArrayOfObject*)newArray(ThreadClass, 0); by freefish
> 
> I don't understand why others did not complain of this.
> Did I misunderstand that?
> 
> thanks,
> 
> Kim, Jongwon.
> 
> -----------------------------------------------------------------
> 
> void add(Thread t) {
>      synchronized (this) {
>          if (destroyed) {
>               throw new IllegalThreadStateException();
>          }
>          if (threads == null) {
>              threads = new Thread[4];
>          } else if (nthreads == threads.length) {
>               Thread newthreads[] = new Thread[nthreads * 2];
>               System.arraycopy(threads, 0, newthreads, 0, nthreads); //
> Exception Here!!
>               threads = newthreads;
>          }
>          threads[nthreads] = t;
> 
>          // This is done last so it doesn't matter in case the
>          // thread is killed
>          nthreads++;
>      }
> }
> 
> ----------------------------------------------------------------
> 
> initThreads(void)
> {
>  /* Get a handle on the thread and thread group classes */
>  ThreadClass = lookupClass(THREADCLASS);
>  assert(ThreadClass != 0);
>  ThreadGroupClass = lookupClass(THREADGROUPCLASS);
>  assert(ThreadGroupClass != 0);
> 
>  /* Create base group */
>  standardGroup = (Hjava_lang_ThreadGroup*)newObject(ThreadGroupClass);
> 
>  assert(standardGroup != 0);
>  unhand(standardGroup)->parent = 0;
>  unhand(standardGroup)->name = makeJavaString("main", 4);
>  unhand(standardGroup)->maxPriority = java_lang_Thread_MAX_PRIORITY;
>  unhand(standardGroup)->destroyed = 0;
>  unhand(standardGroup)->daemon = 0;
>  unhand(standardGroup)->nthreads = 0;
>  unhand(standardGroup)->threads = 0; //
> (HArrayOfObject*)newArray(ThreadClass, 0); by freefish
>  unhand(standardGroup)->ngroups = 0;
>  unhand(standardGroup)->groups =
> (HArrayOfObject*)newArray(ThreadGroupClass, 0);
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>     Kim jongwon
> 
>     freefish at chollian.net
>     freefish at netsgo.com
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~


More information about the kaffe mailing list