[Nickle] nickle: Branch 'master' - 5 commits
Keith Packard
keithp at keithp.com
Mon Jun 11 13:56:25 PDT 2012
compile.c | 8 +++-
configure.ac | 2 -
debian/changelog | 8 ++++
execute.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
sched.c | 8 ++--
stack.c | 6 ++-
stack.h | 2 +
7 files changed, 125 insertions(+), 8 deletions(-)
New commits:
commit c749d6a74d74aff873b93c6cf0883f4863b6d257
Author: Keith Packard <keithp at keithp.com>
Date: Mon Jun 11 13:29:55 2012 -0700
Update to 2.76
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/configure.ac b/configure.ac
index fced9ab..eb85c8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ dnl for licensing information.
AC_PREREQ([2.64])
-AC_INIT([nickle],[2.75],[http://nickle.org],[nickle])
+AC_INIT([nickle],[2.76],[http://nickle.org],[nickle])
AC_CONFIG_SRCDIR([nickle.h])
AC_CONFIG_HEADERS([config.h])
diff --git a/debian/changelog b/debian/changelog
index 95431b4..595fe5e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+nickle (2.76-1) unstable; urgency=low
+
+ * Fix FTBS on Hurd-i386.
+ * Don't crash when using initializer with forward ref type
+ * Fix crashes when MemCollect occurs during Twixt execution
+
+ -- Keith Packard <keithp at keithp.com> Mon, 11 Jun 2012 13:29:18 -0700
+
nickle (2.75-1) unstable; urgency=low
* Fix ref types in array pointer operations (&foo->bar)
commit 131599bc78bd0e3d7ff94535238c3df78092f19d
Author: Keith Packard <keithp at keithp.com>
Date: Mon Jun 11 13:22:15 2012 -0700
Don't erase twixt pointer during JumpContinue until after stack copy
Otherwise, if MemCollect occurs during the stack copy, the twixt's
stack copy can get collected.
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/sched.c b/sched.c
index 9d4722d..9394f17 100644
--- a/sched.c
+++ b/sched.c
@@ -861,6 +861,8 @@ JumpContinue (Value thread, InstPtr *next)
* Going up
*/
twixt = jump->leave;
+ ContinuationSet (&thread->thread.continuation, &twixt->continuation);
+ *next = twixt->leave;
jump->leave = twixt->continuation.twixts;
/*
* Matching element of the twixt chain, next time start
@@ -868,8 +870,6 @@ JumpContinue (Value thread, InstPtr *next)
*/
if (jump->leave == jump->parent)
jump->leave = 0;
- ContinuationSet (&thread->thread.continuation, &twixt->continuation);
- *next = twixt->leave;
}
else if (jump->entering)
{
@@ -877,16 +877,16 @@ JumpContinue (Value thread, InstPtr *next)
* Going down
*/
twixt = jump->entering;
- jump->entering = TwixtNext (jump->entering, jump->enter);
*next = ContinuationSet (&thread->thread.continuation, &twixt->continuation);
+ jump->entering = TwixtNext (jump->entering, jump->enter);
}
else
{
/*
* All done, set to final continuation and drop the jump object
*/
- running->thread.jump = 0;
*next = ContinuationSet (&thread->thread.continuation, jump->continuation);
+ thread->thread.jump = 0;
}
if (!*next)
JumpUnhandledException (thread);
commit 0ced7273d96c6d86c1cf7676efb4321e610f9633
Author: Keith Packard <keithp at keithp.com>
Date: Mon Jun 11 13:18:03 2012 -0700
Check for lost stack chunks
If a stack chunk gets collected, the 'type' field will get
cleared. Check to see if this has happened and abort.
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/stack.c b/stack.c
index e36157a..1bda7f7 100644
--- a/stack.c
+++ b/stack.c
@@ -7,15 +7,16 @@
*/
#include <config.h>
+#include <assert.h>
#include "mem.h"
#include "stack.h"
static void stackMark (void *);
-static DataType stackType = { stackMark, 0, "stackType" };
+DataType stackType = { stackMark, 0, "stackType" };
-static DataType stackChunkType = { 0, 0, "stackChunkType" };
+DataType stackChunkType = { 0, 0, "stackChunkType" };
static void
addChunk (StackObject *stack)
@@ -191,6 +192,7 @@ StackCopy (StackObject *stack)
* Copy stack data and fix stack pointer
*/
*nchunk = *chunk;
+ STACK_CHUNK_ASSERT(chunk->type == &stackChunkType);
/*
* Link into chain
diff --git a/stack.h b/stack.h
index f5d6e26..6447573 100644
--- a/stack.h
+++ b/stack.h
@@ -65,8 +65,10 @@ void
panic (char *, ...);
#define STACK_ASSERT(s) if (!STACK_VALID(s)) panic ("invalid stack\n");
+#define STACK_CHUNK_ASSERT(c) assert((c)->type == &stackChunkType)
#else
#define STACK_ASSERT(s)
+#define STACK_CHUNK_ASSERT(c)
#endif
#if 0
commit e7352c5728c4773c54988308c9b54780e957d003
Author: Keith Packard <keithp at keithp.com>
Date: Mon Jun 11 13:15:51 2012 -0700
Add debug code to check thread validity during execution
If something gets corrupted, it's useful to have this code to help
track it down.
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/execute.c b/execute.c
index 0354080..00b2a2e 100644
--- a/execute.c
+++ b/execute.c
@@ -918,6 +918,102 @@ ThreadStackDump (Value thread)
int dump_inst = 0;
#endif
+#ifdef VALIDATE_EXECUTION
+
+extern DataType FrameType, BoxType, stackType, stackChunkType;
+
+static void
+ObjValid(ObjPtr obj, InstPtr pc)
+{
+ assert(obj->data == &ObjType);
+ assert(0 <= obj->used && obj->used <= obj->size);
+ assert(0 <= obj->used_stat && obj->used_stat <= obj->size_stat);
+ assert(obj->insts <= pc && pc < &obj->insts[obj->used]);
+}
+
+static void
+FrameValid(FramePtr frame)
+{
+ assert (frame->data == &FrameType);
+
+ if (frame->previous)
+ assert (frame->previous->data == &FrameType);
+
+ if (frame->staticLink)
+ assert (frame->staticLink->data == &FrameType);
+
+ assert (ValueIsFunc(frame->function));
+
+ if (frame->frame)
+ assert (frame->frame->data == &BoxType);
+ if (frame->statics)
+ assert (frame->statics->data == &BoxType);
+
+ ObjValid(frame->saveObj, frame->savePc);
+}
+
+static void
+StackValid(StackObject *stack)
+{
+ StackChunk *chunk;
+ StackElement *stackPointer;
+
+ assert(stack->type == &stackType);
+
+ chunk = stack->current;
+ if (chunk) {
+ assert(chunk->type == &stackChunkType);
+ if (chunk->previous)
+ assert (chunk->previous->type == &stackChunkType);
+ }
+
+ stackPointer = stack->stackPointer;
+ assert ((stackPointer == NULL) == (chunk == NULL));
+ if (stackPointer) {
+ assert (&chunk->elements[0] <= stackPointer &&
+ stackPointer <= &chunk->elements[STACK_ENTS_PER_CHUNK]);
+ }
+}
+
+static void
+ThreadValid(Value thread)
+{
+ Thread *t;
+ FramePtr frame;
+ StackObject *stack;
+
+ assert(thread->value.type == &ThreadRep);
+ t = &thread->thread;
+
+ /* Check to make sure object is valid */
+ ObjValid(t->continuation.obj,
+ t->continuation.pc);
+
+ /* Check for valid frame */
+ frame = t->continuation.frame;
+ if (frame)
+ FrameValid(frame);
+
+ stack = t->continuation.stack;
+ if (stack)
+ StackValid(stack);
+}
+
+#define EXEC_HISTORY 256
+Continuation exec_history[EXEC_HISTORY];
+int exec_history_i;
+
+static inline void
+ExecRecord(Value thread)
+{
+ exec_history[exec_history_i] = thread->thread.continuation;
+ exec_history_i = (exec_history_i + 1) % EXEC_HISTORY;
+}
+#else
+#define ThreadValid(t)
+#define ExecRecord(t)
+#endif
+
void
ThreadsRun (Value thread, Value lex)
{
@@ -980,6 +1076,8 @@ ThreadsRun (Value thread, Value lex)
cstack = thread->thread.continuation.stack;
for (j = 0; j < 10; j++)
{
+ ThreadValid(thread);
+ ExecRecord(thread);
stack = 0;
next = inst + 1;
complete = False;
@@ -1462,6 +1560,7 @@ ThreadsRun (Value thread, Value lex)
thread->thread.continuation.pc = inst;
if (thread->thread.next)
ThreadStepped (thread);
+ ThreadValid(thread);
if (running != thread)
break;
}
commit e421d2775c25d717a72d29ac30bf67571655cbe8
Author: Keith Packard <keithp at keithp.com>
Date: Mon Jun 11 13:13:20 2012 -0700
Handle initializers with undefined types.
Emit an error instead of crashing.
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/compile.c b/compile.c
index b5874d4..e718d0e 100644
--- a/compile.c
+++ b/compile.c
@@ -1500,8 +1500,14 @@ CompileInit (ObjPtr obj, ExprPtr expr, Type *type,
ExprPtr stat, CodePtr code)
{
ENTER ();
+ Type *canon_type;
- type = TypeCanon (type);
+ canon_type = TypeCanon (type);
+ if (!canon_type) {
+ CompileError(obj, stat, "Initializer with undefined type '%T'", type);
+ RETURN(obj);
+ }
+ type = canon_type;
if (!expr || expr->base.tag == ANONINIT)
{
More information about the Nickle
mailing list