patch: don't store literal null pointers in saved images

James Bielman <[email protected]> Sun, 07 May 2006 14:09:25 -0700
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
Hi,

In testing our CLSQL application on OpenMCL for AMD64, I ran into the
following issue with CLSQL's Oracle backend.  The DEFVARs for the
various null pointer types will not work in OpenMCL when an image is
saved, because when the image is reloaded, the pointers are marked as
"dead" by OpenMCL:

$ openmcl64 
Welcome to OpenMCL Version 1.1-pre-060505 (Alpha: LinuxX8664)!
? (defvar //ptr (%null-ptr))
//PTR
? //ptr
#<A Null Mac Pointer>
? (save-application "foo" :prepend-kernel t)

$ ./foo
Welcome to OpenMCL Version 1.1-pre-060505 (Alpha: LinuxX8664)!
? //ptr
#<A Dead Mac Pointer>
? (%null-ptr-p //ptr)
> Error: value #<A Dead Mac Pointer> is not of the expected type MACPTR.
> While executing: %NULL-PTR-P, in process listener(2).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.

This patch changes these variables to be symbol macros instead, so a
fresh null pointer is used each time.  There are some testsuite
failures on OpenMCL, but these failed before this patch as well.  All
non-skipped tests pass on SBCL/x86-64.

Thanks,
James

_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel
clsql-null-pointer.diff (application/octet-stream, 1.6 KB)
diff -urw -x '*.lx64fsl' -x '*~' clsql-3.5.7/db-oracle/oracle-api.lisp clsql-devel/db-oracle/oracle-api.lisp
--- clsql-3.5.7/db-oracle/oracle-api.lisp	2005-11-14 18:44:14.000000000 -0800
+++ clsql-devel/db-oracle/oracle-api.lisp	2006-05-07 13:22:19.000000000 -0700
@@ -38,8 +38,10 @@
 (uffi:def-foreign-type oci-stmt :pointer-void)
 
 
-(defvar +null-void-pointer+ (uffi:make-null-pointer :void))
-(defvar +null-void-pointer-pointer+ (uffi:make-null-pointer :pointer-void))
+(define-symbol-macro +null-void-pointer+
+    (uffi:make-null-pointer :void))
+(define-symbol-macro +null-void-pointer-pointer+
+    (uffi:make-null-pointer :pointer-void))
 
 ;;; Check an OCI return code for erroricity and signal a reasonably
 ;;; informative condition if so.
diff -urw -x '*.lx64fsl' -x '*~' clsql-3.5.7/db-oracle/oracle-sql.lisp clsql-devel/db-oracle/oracle-sql.lisp
--- clsql-3.5.7/db-oracle/oracle-sql.lisp	2006-02-28 08:07:59.000000000 -0800
+++ clsql-devel/db-oracle/oracle-sql.lisp	2006-05-07 13:27:58.000000000 -0700
@@ -37,11 +37,11 @@
 (defmacro deref-vp (foreign-object)
   `(the vp-type (uffi:deref-pointer (the vpp-type ,foreign-object) :pointer-void)))
 
-(defvar +unsigned-char-null-pointer+
+(define-symbol-macro +unsigned-char-null-pointer+
   (uffi:make-null-pointer :unsigned-char))
-(defvar +unsigned-short-null-pointer+
+(define-symbol-macro +unsigned-short-null-pointer+
   (uffi:make-null-pointer :unsigned-short))
-(defvar +unsigned-int-null-pointer+
+(define-symbol-macro +unsigned-int-null-pointer+
   (uffi:make-null-pointer :unsigned-int))
 
 ;; constants - from OCI?