[kaffe] CVS kaffe (hkraemer): fixed race between gc invocation and thread initialization
Kaffe CVS
cvs-commits at kaffe.org
Tue Dec 21 03:51:16 PST 2004
PatchSet 5699
Date: 2004/12/21 11:46:51
Author: hkraemer
Branch: HEAD
Tag: (none)
Log:
fixed race between gc invocation and thread initialization
Members:
ChangeLog:1.3244->1.3245
kaffe/kaffevm/threadData.h:1.4->1.5
kaffe/kaffevm/kaffe-gc/gc-refs.c:1.7->1.8
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3244 kaffe/ChangeLog:1.3245
--- kaffe/ChangeLog:1.3244 Tue Dec 21 08:47:08 2004
+++ kaffe/ChangeLog Tue Dec 21 11:46:51 2004
@@ -1,3 +1,12 @@
+2004-12-21 Helmer Kraemer <hkraemer at freenet.de>
+
+ * kaffe/kaffevm/threadData.h (THREAD_DATA_INITIALIZED): new macro
+
+ * kaffe/kaffevm/kaffe-gc/gc-refs.c (liveThreadWalker): properly handle
+ partially initialized threads
+
+ Reported by: Alexander Boettcher <ab764283 at os.inf.tu-dresden.de>
+
2004-12-21 Adam Heath <doogie at brainfood.com>
* AUTHORS:
Index: kaffe/kaffe/kaffevm/threadData.h
diff -u kaffe/kaffe/kaffevm/threadData.h:1.4 kaffe/kaffe/kaffevm/threadData.h:1.5
--- kaffe/kaffe/kaffevm/threadData.h:1.4 Wed Jul 7 16:05:13 2004
+++ kaffe/kaffe/kaffevm/threadData.h Tue Dec 21 11:46:54 2004
@@ -38,4 +38,6 @@
int needOnStack;
} threadData;
+#define THREAD_DATA_INITIALIZED(td) ((td)->jniEnv != NULL)
+
#endif
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-refs.c
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-refs.c:1.7 kaffe/kaffe/kaffevm/kaffe-gc/gc-refs.c:1.8
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-refs.c:1.7 Sun Dec 19 06:41:29 2004
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-refs.c Tue Dec 21 11:46:54 2004
@@ -154,14 +154,22 @@
{
Collector *c = (Collector *)private;
threadData *thread_data = KTHREAD(get_data)(tid);
- Hjava_lang_VMThread *thread = (Hjava_lang_VMThread *)thread_data->jlThread;
- KGC_markObject(c, NULL, unhand(thread)->thread);
- KGC_markObject(c, NULL, thread);
-
- if (thread_data->exceptObj != NULL)
+ /* if the gc is invoked while a new thread is being
+ * initialized, we should not make any assumptions
+ * about what is stored in its thread_data
+ */
+ if (THREAD_DATA_INITIALIZED(thread_data))
{
- KGC_markObject(c, NULL, thread_data->exceptObj);
+ Hjava_lang_VMThread *thread = (Hjava_lang_VMThread *)thread_data->jlThread;
+
+ KGC_markObject(c, NULL, unhand(thread)->thread);
+ KGC_markObject(c, NULL, thread);
+
+ if (thread_data->exceptObj != NULL)
+ {
+ KGC_markObject(c, NULL, thread_data->exceptObj);
+ }
}
TwalkThread(c, tid);
More information about the kaffe
mailing list