[cffi-devel] Bus error ... ?! Help, please ...

Frank Goenninger frgo at me.com
Fri May 8 17:08:23 UTC 2009


Am 08.05.2009 um 15:43 schrieb Leslie P. Polzer:

>
> Frank Goenninger wrote:
>
>> Oh, btw, that happens no matter what function from OpenGL I try to
>> call... So, something very fundamental must be wrong here. I just
>> can't see what ... Please help!
>
> Have you asked gdb for help, too?
>
>  Leslie


Hadn't until you asked. But now I have. I started AllegroCL with

$ alisp

and then loaded my system via ASDF.

CL-USER > (asdf 'cello-nx)

... messages as expected ...

CL-USER >

At this point I started gdb and attached to the process. After  
enabling out logging I continued the alisp process.

CL-USER > (cello-nx::gl-get-version)

which caused the following output:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000

I then asked gdb to print the backtrace:

0x95a1d2ec in glGetError ()
#0  0x95a1d2ec in glGetError ()
#1  0x00243b68 in ff_funcall () at qrff.s:253
#2  0x002439b2 in ff_apply () at qrff.s:97
#3  0x032e100b in ?? ()
#4  0x10a2fc05 in ?? ()
#5  0x1088f3e5 in ?? ()
#6  0x1066add8 in ?? ()
#7  0x0310dab8 in ?? ()
#8  0x0331b281 in ?? ()
#9  0x03310f1d in ?? ()
#10 0x03320a17 in ?? ()
#11 0x0310e680 in ?? ()
#12 0x00259097 in apply () at qruntime.s:1901
#13 0x0331e05e in ?? ()
#14 0x03331c6f in ?? ()
#15 0x00259097 in apply () at qruntime.s:1901
#16 0x03016a08 in ?? ()
#17 0x0332e9a2 in ?? ()
#18 0x03016f9c in ?? ()
#19 0x0310e8c7 in ?? ()
#20 0x002544be in first_lisp_thread () at qrstorag.s:3081
#21 0x002542aa in _start_reborn_lisp () at qrstorag.s:2889
#22 0x00233f65 in startup_lisp () at c/startup.c:1290
#23 0x00253de7 in cont_setstack () at qrstorag.s:2408
#24 0x00253c7b in _first_lisp_thread_init () at qrstorag.s:2288

The two functions involved here are:
(point where the bus error occurs is marked <<<<<<<<<<)

(defun! gl-check-error (&optional (id :anonymous) announce-success)
   (if (null (find id *gl-list-of-ids-excluded-from-error-checking*))
       (if (and (boundp '*gl-begun*) *gl-begun*)
           (progn
             (logmsg :DEBUG *this-file* *this-module* 3
                     "Not checking OpenGL errors inside glBegin/glEnd  
at ~S." id))
           (let ((e (%glGetError))) ;; ffi glGetError  <<<<<<<<<<<
             (if (= e 0)
                 (when announce-success
                   (logmsg :DEBUG *this-file* *this-module* 4
                           "No OpenGL error found at ~S" id))
                 (progn
                   (if (boundp '*gl-stop*)
                       (logmsg :ERROR *this-file* *this-module* 5
                               "*gl-stop* bound at ~S." id))
                   (setf *gl-stop* t)
                   (let* ((err-text (foreign-string-to-lisp  
(%gluErrorString e)))
                          (msg (format nil "OpenGL error ~d (\"~A\")  
at ~S" e  err-text id)))
                     (logmsg :ERROR *this-file* *this-module* 6 msg)
                     (when *gl-break-on-stop*
                       (break msg)))))))))

(defun gl-get-version ()
   (gl-check-error t)
   (let ((version-string (%glGetString GL_VERSION)))
     (break)
     (foreign-string-to-lisp version-string)))

Ok, so back to my assessment: Something fundamental not working here.

I do get the same error happening when I do not call the cl-check- 
error function but go straight to call %glGetString (which calls  
glGetString ffi function).

It just seems as if the OpenGL lib is not really loaded and the  
function address of the foreign functions are null pointers...

Any further suggestions of what I should analyze in gdb or elsewhere?  
Educated guesses on the causes? Thanks!!!

Ah, you know, it worked last time (half a year ago, on a  different OS  
patch level of OS X, with fewer patches loaded for AllegroCL and older  
version of CFFI).

Cheers
     Frank

--
   Frank Goenninger

   Cell: 	+49 175 4321058
   E-Mail: 	frgo at me.com









More information about the cffi-devel mailing list