[Openmcl-devel] CCL-1.4 CLSQL-5.0.4 WinXP(32)

Stefan Izota stefan.izota at gmail.com
Fri Feb 19 13:14:24 UTC 2010


Thanks Gary. Your proposed workaround does fix the problem (at least for 
the moment). I'll have to dig deeper into the uffi package.

Regards,
Stefan

Gary Byers wrote:
> Both uffi-1.8.6 and clsql-5.0.4 are recent versions; this may be a new 
> bug.
>
> UFFI:CONVERT-FROM-FOREIGN-STRING is a macro; it decides whether to call
> CCL:%STR-FROM-PTR or CCL:%GET-CSTRING based on whether its LENGTH keyword
> argument is null at macroexpand time.
>
> I imagine that if you do:
>
> ? (macroexpand
>        '(uffi:convert-from-foreign-string char-ptr
>                                           :null-terminated-p nil
>                                           :length length
>                                           :encoding encoding))
>
> you'll get:
>
> (CCL:%STR-FROM-PTR CHAR-PTR LENGTH)
>
> If that form was compiled and the value of LENGTH was NIL at runtime,
> you'll get the error that you got (CCL:%STR-FROM-PTR's second argument
> should be a non-negative FIXNUM, and one use of it in CCL:%STR-FROM-PTR
> expects it to be less than ARRAY-TOTAL-SIZE-LIMIT.)
>
> I don't think that UFFI:CONVERT-FROM-FOREIGN-STRING can work this way
> in general.  You might be able to work around this problem by changing
> the last clause in CONVERT-RAW-FIELD (in clsql/uffi/clsql-uffi.lisp) 
> from:
>
>        (t
>         (uffi:convert-from-foreign-string char-ptr
>                                           :null-terminated-p nil
>                                           :length length
>                                           :encoding encoding))
>
> to:
>
>        (t
>         (if length
>           (uffi:convert-from-foreign-string char-ptr
>                                            :null-terminated-p nil
>                                            :length length
>                                            :encoding encoding)
>           (uffi:convert-from-foreign-string char-ptr
>                                            :null-terminated-p t
>                                            :encoding encoding))
>
> (The ENCODING argument has the same problem; working around that is 
> left as
> an exercise.)
>
> I'm sure that there's a better way to handle all of this.
>
>
>
>
>
> On Fri, 19 Feb 2010, Stefan Izota wrote:
>
>> Hi everybody,
>>
>> I encountered a little problem with Clozure CL 1.4 in WindowXP (32 bit)
>> and CLSQL-5.0.4.
>>
>> I am using something like this:
>>
>> (require 'asdf)
>>
>> (push #p"d:/programs/ccl/extra/uffi-1.8.6/" asdf:*central-registry*)
>> (push #p"d:/programs/ccl/extra/clsql-5.0.4/" asdf:*central-registry*)
>>
>> (push :win32 *features*)
>>
>> (asdf:oos 'asdf:load-op 'uffi)
>> (asdf:oos 'asdf:load-op 'clsql)
>>
>> (push #p"d:/programs/sqlite3/" clsql-sys:*foreign-library-search-paths*)
>> (push #p"d:/programs/ccl/extra/" 
>> clsql-sys:*foreign-library-search-paths*)
>>
>> (asdf:oos 'asdf:load-op 'clsql-sqlite3)
>>
>> (clsql:connect '("d:/db/test.sqlite") :database-type :sqlite3)
>>
>> (clsql:def-view-class foo ()
>> ((id
>>   :db-kind :key
>>   :db-constraints :not-null
>>   :type integer
>>   :initarg :id)
>>  (name
>>   :accessor name
>>   :type (string 30)
>>   :initarg :name))
>> (:base-table foo))
>>
>> (clsql:select 'foo)
>>
>> and I got the following
>>
>> value NIL is not of the expected type (UNSIGNED-BYTE 24).
>>  [Condition of type TYPE-ERROR]
>>
>> Restarts:
>> 0: [RETRY] Retry SLIME REPL evaluation request.
>> 1: [ABORT] Return to SLIME's top level.
>> 2: [ABORT-BREAK] Reset this thread
>> 3: [ABORT] Kill this thread
>>
>> Backtrace:
>> 0: (%STR-FROM-PTR #<A Foreign Pointer #x1193930> NIL NIL)
>> 1: ((:INTERNAL CLSQL-SQLITE3::EXTRACT-ROW-DATA
>> (CLSQL-SYS:DATABASE-QUERY (T CLSQL-SQLITE3:SQLITE3-DATABASE T T))))
>> 2: (#<STANDARD-METHOD CLSQL-SYS:DATABASE-QUERY (T
>> CLSQL-SQLITE3:SQLITE3-DATABASE T T)> "SELECT FOO.NAME,FOO.ID FROM FOO"
>> #<SQLITE3-DATABASE d:/work/scheme/erp/data/erp.db.sqlite OPEN #x904D92E>
>> :AUTO T)
>> 3: (CCL::%%STANDARD-COMBINED-METHOD-DCODE ((#<STANDARD-METHOD
>> CLSQL-SYS:DATABASE-QUERY :BEFORE (T CLSQL-SYS:DATABASE T T)>) NIL ..)
>> 13615756)
>> 4: (NIL #<Unknown Arguments>)
>> 5: (#<STANDARD-METHOD CLSQL-SYS:QUERY (STRING)> "SELECT FOO.NAME,FOO.ID
>> FROM FOO" :DATABASE #<SQLITE3-DATABASE
>> d:/work/scheme/erp/data/erp.db.sqlite OPEN #x904D92E> :RESULT-TYPES
>> :AUTO :FLATP NIL :FIELD-..
>> 6: (CCL::%%CHECK-KEYWORDS #(1 #(:FIELD-NAMES :FLATP :RESULT-TYPES
>> :DATABASE) #<METHOD-FUNCTION CLSQL-SYS:QUERY (STRING)>) 13615783)
>> 7: (NIL #<Unknown Arguments>)
>> 8: (CCL::%%CHECK-KEYWORDS #(1 #(:FIELD-NAMES :FLATP :RESULT-TYPES
>> :DATABASE) #<METHOD-FUNCTION CLSQL-SYS:QUERY
>> (CLSQL-SYS::%SQL-EXPRESSION)>) 13615803)
>> 9: (NIL #<Unknown Arguments>)
>> 10: (CLSQL-SYS:SELECT #<SQL-IDENT-ATTRIBUTE FOO.NAME>
>> #<SQL-IDENT-ATTRIBUTE FOO.ID> :FROM (#<SQL-IDENT-TABLE FOO>)
>> :RESULT-TYPES :AUTO :REFRESH NIL)
>> 11: (CLSQL-SYS::FIND-ALL (FOO) :REFRESH NIL)
>> 12: (CLSQL-SYS:SELECT FOO)
>> 13: (CCL::CALL-CHECK-REGS CLSQL-SYS:SELECT FOO)
>> 14: (SWANK::EVAL-REGION "(clsql:select 'foo)\n")
>> 15: ((:INTERNAL SWANK::REPL-EVAL))
>> 16: (SWANK::TRACK-PACKAGE #<COMPILED-LEXICAL-CLOSURE (:INTERNAL
>> SWANK::REPL-EVAL) #x90B2396>)
>> 17: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation
>> request." #<COMPILED-LEXICAL-CLOSURE (:INTERNAL SWANK::REPL-EVAL)
>> #x90B23E6>)
>> 18: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<COMPILED-LEXICAL-CLOSURE
>> (:INTERNAL SWANK::REPL-EVAL) #x90B240E>)
>> 19: (SWANK::REPL-EVAL "(clsql:select 'foo)\n")
>> 20: (CCL::CALL-CHECK-REGS SWANK:LISTENER-EVAL "(clsql:select 'foo)\n")
>> 21: (SWANK::EVAL-FOR-EMACS (SWANK:LISTENER-EVAL "(clsql:select 'foo)\n")
>> "COMMON-LISP-USER" 26)
>> 22: (SWANK::PROCESS-REQUESTS NIL)
>> 23: ((:INTERNAL SWANK::HANDLE-REQUESTS))
>> 24: (#<Anonymous Function #x8C0E2BE> #<Compiled-function
>> SWANK:SWANK-DEBUGGER-HOOK #x8C9E3D6> #<COMPILED-LEXICAL-CLOSURE
>> (:INTERNAL SWANK::HANDLE-REQUESTS) #x90B27FE>)
>> 25: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-OUTPUT* .
>> #<SWANK-BACKEND::SLIME-OUTPUT-STREAM #x8D428B6>) (*STANDARD-INPUT* .
>> #<SWANK-BACKEND::SLIME-INPUT-STREAM #x8D42AEE>) ..)))
>> #<COMPILED-LEXICAL-CLOSURE (..
>> 26: (SWANK::CALL-WITH-CONNECTION #<CONNECTION #x8D16DDE>
>> #<COMPILED-LEXICAL-CLOSURE (:INTERNAL SWANK::HANDLE-REQUESTS) 
>> #x90B27FE>)
>> 27: (SWANK::HANDLE-REQUESTS #<CONNECTION #x8D16DDE> NIL)
>> 28: (SWANK::CALL-WITH-BINDINGS NIL #<COMPILED-LEXICAL-CLOSURE (:INTERNAL
>> SWANK::SPAWN-REPL-THREAD) #x8D4BFDE>)
>> 29: (CCL::RUN-PROCESS-INITIAL-FORM #<PROCESS repl-thread(11) [Active]
>> #x8D42E56> (#<COMPILED-LEXICAL-CLOSURE (:INTERNAL
>> CCL::%PROCESS-RUN-FUNCTION) #x8D42D16>))
>> 30: ((:INTERNAL (CCL::%PROCESS-PRESET-INTERNAL (PROCESS))) #<PROCESS
>> repl-thread(11) [Active] #x8D42E56> (#<COMPILED-LEXICAL-CLOSURE
>> (:INTERNAL CCL::%PROCESS-RUN-FUNCTION) #x8D42D16>))
>> 31: ((:INTERNAL CCL::THREAD-MAKE-STARTUP-FUNCTION))
>>
>> I used
>>
>> (clsql:create-view-from-class 'foo)
>>
>> (defvar foo1 (make-instance 'foo :id 1 :name 'foo1))
>>
>> (clsql:update-records-from-instance foo1)
>>
>> to create the table and insert one row.
>>
>> The same error occurs if I the default listener:
>>
>> ? (clsql:select 'foo)
>> > Error: value NIL is not of the expected type (UNSIGNED-BYTE 24).
>> > While executing: %STR-FROM-PTR, in process listener(1).
>> > Type :POP to abort, :R for a list of available restarts.
>> > Type :? for other options.
>> 1 > :pop
>>
>>
>> Any ideas?
>>
>> P.S. I sent this email to the CLSQL list also (from some reason I could
>> not subscribe to that list).
>> P.S.2 I am new Clozure Cl (and Lisp in general).
>>
>> Thanks for your time,
>> Stefan
>>
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
>>
>>
>




More information about the Openmcl-devel mailing list