bug-guile
[Top][All Lists]
Advanced

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

bug#13074: VM Segfaults with Bad `Call' Instruction


From: Noah Lavine
Subject: bug#13074: VM Segfaults with Bad `Call' Instruction
Date: Tue, 4 Dec 2012 22:26:52 -0500

The following patch fixes the problem for me:

diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 7153ab5..dff2ab2 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -793,7 +793,9 @@ VM_DEFINE_INSTRUCTION (55, call, "call", 1, -1, 1)
 
   VM_HANDLE_INTERRUPTS;
 
-  if (SCM_UNLIKELY (!SCM_PROGRAM_P (program)))
+  if (SCM_UNLIKELY (program == NULL))
+    goto vm_error_bad_instruction;
+  else if (SCM_UNLIKELY (!SCM_PROGRAM_P (program)))
     {
       if (SCM_STRUCTP (program) && SCM_STRUCT_APPLICABLE_P (program))
         {

Any objections if I apply it to stable-2.0? (Or master?)

Noah


On Mon, Dec 3, 2012 at 10:06 PM, Noah Lavine <address@hidden> wrote:
Hello,

This is an interesting bug, because the only way to hit it (as far as I can tell) is to mess up when writing a compiler. However, I did mess up, and I discover that I can generate a `call' instruction in the trunk VM where the procedure to call will be 0x0. Then the VM will try to check whether the procedure is really a procedure, and Guile will segfault at line 796 of v-i-system.c.

I think the correct behavior would be to throw a `vm-bad-instruction' error instead. The fix should be pretty simple - just check if program is 0x0 and jump to vm-bad-instruction in that case.

Noah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]