NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/37966: libobjc on NetBSD 4.0 only single threaded



>Number:         37966
>Category:       toolchain
>Synopsis:       libobjc on NetBSD 4.0 only single threaded
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 05 22:25:00 +0000 2008
>Originator:     David Wetzel
>Release:        NetBSD 4.0
>Environment:
        
        
System: NetBSD netra.turbocat.de 4.0 NetBSD 4.0
Architecture: sparc64
Machine: sparc64
>Description:
        libobjc on NetBSD 4.0 only single threaded
        This stops any Objective-C program to work with multiple threads if the 
runtime is used.
>How-To-Repeat:
Makefile: -------------------------------------------
all: threadtest

threadtest: main.m
        gcc -ggdb -o threadtest main.m -lobjc -pthread

clean:
        rm -f threadtest *~
-------------------------------------------
main.m:
#include <stdio.h>
#include <unistd.h>

#include <objc/objc.h>
#include <objc/objc-api.h>
#include <objc/Object.h>

@interface MyClass : Object
{
  char *myName;
}
-(void)setMyName:(char *)n;
-(char *)myName;
@end

@implementation MyClass
-(void)setMyName:(char *)n
{
  size_t len;
  if (myName) {
    if (strcmp(myName,n)) return;
    objc_free(myName);
  }
  len = strlen(n)+1;
  myName = objc_malloc(len);
  strcpy(myName,n);
}
-(char *)myName
{
  return myName;
}
-(void)start
{
  printf("detached thread started!\n");
}
@end

static void
becomeMultiThreaded(void)
{
  printf("becomming multihreaded!\n");
}

int
main(int argc, char *argv[])
{
  id o = [MyClass new];
  char *c;
  objc_thread_callback cb;
  objc_thread_t rv;

  [o setMyName:"thread"];
  c = [o myName];

  printf("Testing: %s\n",c);

  cb = objc_set_thread_callback(becomeMultiThreaded);
  printf("Old Callback: %p\n",cb);

  rv = objc_thread_detach(@selector(start), o, nil);
  printf("detach value: %p\n",rv);

  sleep(1);

  return 0;
}
-------------------------------------

make and run the program.

Fail looks like:

dave@netra>./threadtest 
Testing: thread
Old Callback: 0x0
detach value: 0x0

dave@netra>uname -rms
NetBSD 4.0 sparc64

Success looks like:

dave@alice>./threadtest 
Testing: thread
Old Callback: 0x0
detach value: 0xbb000000
becomming multihreaded!
detached thread started!

dave@alice>uname -rms
NetBSD 3.1 i386

>Fix:
        

>Unformatted:
        
        



Home | Main Index | Thread Index | Old Index