diff options
author | stas <stas@FreeBSD.org> | 2009-05-10 03:54:23 +0800 |
---|---|---|
committer | stas <stas@FreeBSD.org> | 2009-05-10 03:54:23 +0800 |
commit | 49dc26ae286332af6e0564e6c46d5f4ba694fe89 (patch) | |
tree | 299b7fbbb221a3833042b8c789b1c23b070e5479 /lang/ocaml | |
parent | 7d70bfcc0117d2ebe65829efa486aec995ba0db3 (diff) | |
download | freebsd-ports-gnome-49dc26ae286332af6e0564e6c46d5f4ba694fe89.tar.gz freebsd-ports-gnome-49dc26ae286332af6e0564e6c46d5f4ba694fe89.tar.zst freebsd-ports-gnome-49dc26ae286332af6e0564e6c46d5f4ba694fe89.zip |
- Fix a couple of serious bugs in threading code (#4666 and #4678).
Obtained from: ocaml cvs
Diffstat (limited to 'lang/ocaml')
-rw-r--r-- | lang/ocaml/Makefile | 1 | ||||
-rw-r--r-- | lang/ocaml/files/patch-#4666 | 111 | ||||
-rw-r--r-- | lang/ocaml/files/patch-#4678 | 19 |
3 files changed, 131 insertions, 0 deletions
diff --git a/lang/ocaml/Makefile b/lang/ocaml/Makefile index 58c1d8ef4d43..7b9834a9fdca 100644 --- a/lang/ocaml/Makefile +++ b/lang/ocaml/Makefile @@ -7,6 +7,7 @@ PORTNAME= ocaml PORTVERSION= 3.11.0 +PORTREVISION= 1 CATEGORIES= lang MASTER_SITES= http://caml.inria.fr/distrib/${DISTNAME:R}/ \ ftp://ftp.inria.fr/INRIA/caml-light/${DISTNAME:R}/ \ diff --git a/lang/ocaml/files/patch-#4666 b/lang/ocaml/files/patch-#4666 new file mode 100644 index 000000000000..8a05329a5268 --- /dev/null +++ b/lang/ocaml/files/patch-#4666 @@ -0,0 +1,111 @@ +--- otherlibs/systhreads/posix.c 2008/09/27 10:46:55 1.58 ++++ otherlibs/systhreads/posix.c 2008/12/14 18:16:38 1.58.2.1 +@@ -11,7 +11,7 @@ + /* */ + /***********************************************************************/ + +-/* $Id: posix.c,v 1.58 2008/09/27 10:46:55 xleroy Exp $ */ ++/* $Id: posix.c,v 1.58.2.1 2008/12/14 18:16:38 xleroy Exp $ */ + + /* Thread interface for POSIX 1003.1c threads */ + +@@ -111,6 +111,9 @@ static pthread_mutex_t caml_runtime_mute + /* Condition signaled when caml_runtime_busy becomes 0 */ + static pthread_cond_t caml_runtime_is_free = PTHREAD_COND_INITIALIZER; + ++/* Whether the ``tick'' thread is already running */ ++static int caml_tick_thread_running = 0; ++ + /* The key used for storing the thread descriptor in the specific data + of the corresponding Posix thread. */ + static pthread_key_t thread_descriptor_key; +@@ -332,8 +335,6 @@ static void * caml_thread_tick(void * ar + static void caml_thread_reinitialize(void) + { + caml_thread_t thr, next; +- pthread_t tick_pthread; +- pthread_attr_t attr; + struct channel * chan; + + /* Remove all other threads (now nonexistent) +@@ -353,24 +354,21 @@ static void caml_thread_reinitialize(voi + pthread_cond_init(&caml_runtime_is_free, NULL); + caml_runtime_waiters = 0; /* no other thread is waiting for the RTS */ + caml_runtime_busy = 1; /* normally useless */ ++ /* Tick thread is not currently running in child process, will be ++ re-created at next Thread.create */ ++ caml_tick_thread_running = 0; + /* Reinitialize all IO mutexes */ + for (chan = caml_all_opened_channels; + chan != NULL; + chan = chan->next) { + if (chan->mutex != NULL) pthread_mutex_init(chan->mutex, NULL); + } +- /* Fork a new tick thread */ +- pthread_attr_init(&attr); +- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); +- pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL); + } + + /* Initialize the thread machinery */ + + value caml_thread_initialize(value unit) /* ML */ + { +- pthread_t tick_pthread; +- pthread_attr_t attr; + value mu = Val_unit; + value descr; + +@@ -415,12 +413,6 @@ value caml_thread_initialize(value unit) + caml_channel_mutex_lock = caml_io_mutex_lock; + caml_channel_mutex_unlock = caml_io_mutex_unlock; + caml_channel_mutex_unlock_exn = caml_io_mutex_unlock_exn; +- /* Fork the tick thread */ +- pthread_attr_init(&attr); +- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); +- caml_pthread_check( +- pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL), +- "Thread.init"); + /* Set up fork() to reinitialize the thread machinery in the child + (PR#4577) */ + pthread_atfork(NULL, NULL, caml_thread_reinitialize); +@@ -488,6 +480,7 @@ value caml_thread_new(value clos) + { + pthread_attr_t attr; + caml_thread_t th; ++ pthread_t tick_pthread; + value mu = Val_unit; + value descr; + int err; +@@ -526,12 +519,12 @@ value caml_thread_new(value clos) + th->prev = curr_thread; + curr_thread->next->prev = th; + curr_thread->next = th; +- /* Fork the new thread */ ++ /* Create the new thread */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + err = pthread_create(&th->pthread, &attr, caml_thread_start, (void *) th); + if (err != 0) { +- /* Fork failed, remove thread info block from list of threads */ ++ /* Creation failed, remove thread info block from list of threads */ + th->next->prev = curr_thread; + curr_thread->next = th->next; + #ifndef NATIVE_CODE +@@ -541,6 +534,16 @@ value caml_thread_new(value clos) + caml_pthread_check(err, "Thread.create"); + } + End_roots(); ++ /* Create the tick thread if not already done. ++ Because of PR#4666, we start the tick thread late, only when we create ++ the first additional thread in the current process*/ ++ if (! caml_tick_thread_running) { ++ caml_tick_thread_running = 1; ++ pthread_attr_init(&attr); ++ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); ++ err = pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL); ++ caml_pthread_check(err, "Thread.create"); ++ } + return descr; + } + diff --git a/lang/ocaml/files/patch-#4678 b/lang/ocaml/files/patch-#4678 new file mode 100644 index 000000000000..30552c677422 --- /dev/null +++ b/lang/ocaml/files/patch-#4678 @@ -0,0 +1,19 @@ +--- otherlibs/systhreads/posix.c 2008/12/14 18:16:38 1.58.2.1 ++++ otherlibs/systhreads/posix.c 2009/03/28 17:35:59 1.58.2.2 +@@ -11,7 +11,7 @@ + /* */ + /***********************************************************************/ + +-/* $Id: posix.c,v 1.58.2.1 2008/12/14 18:16:38 xleroy Exp $ */ ++/* $Id: posix.c,v 1.58.2.2 2009/03/28 17:35:59 xleroy Exp $ */ + + /* Thread interface for POSIX 1003.1c threads */ + +@@ -393,6 +393,7 @@ value caml_thread_initialize(value unit) + curr_thread->descr = descr; + curr_thread->next = curr_thread; + curr_thread->prev = curr_thread; ++ curr_thread->backtrace_last_exn = Val_unit; + #ifdef NATIVE_CODE + curr_thread->exit_buf = &caml_termination_jmpbuf; + #endif |