[Top][All Lists]

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

[Chicken-users] segfault using cairo/SDL

From: Markus Klotzbuecher
Subject: [Chicken-users] segfault using cairo/SDL
Date: Wed, 21 Dec 2011 21:11:40 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Dear All,

I'm trying to use the cairo and sdl eggs for a small visualization
tool. One thing I would like to do is to use the mouse to move around
the current figure by clicking and holding it. However, I am getting
frequent segfaults after a few seconds of this moving around. The
crash happens both when running compiled and interpreted. Below an
slightly modified version of the test-cairo.scm from the cairo egg
that implements this "dragging" (I would have pasted it to , but the service seems down)

Is anyone else using these eggs and has seen such problems? Does
anyone have a suggestions how to track this down?

I using debian testing amd64, sdl-egg v0.5.4, cairo-egg 0.1.12.

CHICKEN Version 4.7.0 
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2011-09-05 on (Linux)

I'll be pleased to provide more information.
Thanks in advance!



#0  0x00007fdd81c9476f in f_2129 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>) at cairo.c:3963
#1  0x00007fdd89a59b18 in C_values () from /usr/lib/
#2  0x00007fdd81c9afbe in f_2124 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>, t2=<optimized out>)
    at cairo.c:3949
#3  0x0000000000401daa in f_438 (c=<optimized out>, t0=140736279960048, 
t1=<optimized out>) at test-cairo.c:1661
#4  0x00007fdd81ca0893 in f_1614 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>) at cairo.c:4702
#5  0x00007fdd89a59b18 in C_values () from /usr/lib/
#6  0x00007fdd81c994a6 in f_1609 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>, t2=<optimized out>, 
    t3=<optimized out>) at cairo.c:4684
#7  0x00000000004026cf in f_435 (c=<optimized out>, t0=140736279960480, 
t1=<optimized out>) at test-cairo.c:1653
#8  0x00007fdd81c940b5 in f_1497 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>) at cairo.c:4873
#9  0x00007fdd89a59b18 in C_values () from /usr/lib/
#10 0x00007fdd81c98f13 in f_1492 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>, t2=<optimized out>, 
    t3=<optimized out>, t4=<optimized out>, t5=3, t6=140589480767760) at 
#11 0x00000000004027c7 in f_432 (c=<optimized out>, t0=140736279961536, 
t1=<optimized out>) at test-cairo.c:1640
#12 0x00007fdd81c946b5 in f_2087 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>) at cairo.c:4023
#13 0x00007fdd89a59b18 in C_values () from /usr/lib/
#14 0x00007fdd81c9ada3 in f_2082 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>, t2=<optimized out>, 
    t3=<optimized out>, t4=<optimized out>, t5=140736279961424, 
t6=140736279960944) at cairo.c:4005
#15 0x0000000000401e11 in f_449 (c=<optimized out>, t0=140736279961296, 
t1=140736279960944) at test-cairo.c:1627
#16 0x00007fdd89a5d27b in C_minus () from /usr/lib/
#17 0x0000000000406c8e in f_453 (c=<optimized out>, t0=140736279961336, 
t1=140736279961184) at test-cairo.c:1619
#18 0x00007fdd81c94f73 in f_2223 (c=<optimized out>, t0=<optimized out>, 
t1=140736279961336, t2=<optimized out>)
    at cairo.c:3771
#19 0x00000000004028c5 in f_445 (c=<optimized out>, t0=140736279961568, 
t1=<optimized out>) at test-cairo.c:1611
#20 0x00007fdd81c94e63 in f_2213 (c=<optimized out>, t0=<optimized out>, 
t1=140736279961568, t2=<optimized out>)
    at cairo.c:3791
#21 0x00000000004029ce in f_429 (c=<optimized out>, t0=140736279961872, 
t1=<optimized out>) at test-cairo.c:1596
#22 0x00007fdd81c944d1 in f_1929 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>) at cairo.c:4211
#23 0x00007fdd89a59b18 in C_values () from /usr/lib/
#24 0x00007fdd81c9a56e in f_1924 (c=<optimized out>, t0=<optimized out>, 
t1=<optimized out>, t2=<optimized out>)
    at cairo.c:4197
#25 0x0000000000402ab1 in f_426 (c=<optimized out>, t0=140589481276352, 
t1=<optimized out>) at test-cairo.c:1581
#26 0x00007fdd81c96528 in f_2512 (c=<optimized out>, t0=140589481276312, 
t1=140736279962032) at cairo.c:3337
#27 0x00007fdd89849a75 in ?? () from /usr/lib/
#28 0x00007fdd89a36234 in ?? () from /usr/lib/
#29 0x00007fdd89a5b112 in C_allocate_vector () from /usr/lib/
#30 0x00007fdd8983e633 in ?? () from /usr/lib/
#31 0x00007fdd898377ed in ?? () from /usr/lib/
#32 0x00007fdd89a39368 in CHICKEN_run () from /usr/lib/
#33 0x00007fdd89a3941b in CHICKEN_main () from /usr/lib/
#34 0x00007fdd88f9aead in __libc_start_main (main=<optimized out>, 
argc=<optimized out>, ubp_av=<optimized out>, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    at libc-start.c:228
#35 0x00000000004010b5 in _start ()

; A test program for the Cairo bindings
; Michael Bridgen <address@hidden>
; Tony Garnock-Jones <address@hidden>

(use fmt)
(use posix)
(use sdl)
(use cairo)
(import chicken scheme foreign)

;; only required on OS X
;; (declare
;;  (foreign-declare "#include <SDL/SDL.h>\n")
;;  (run-time-macros))
;; (foreign-code "SDL_Init(SDL_INIT_EVERYTHING);")


(define maxx 640)
(define maxy 480)

(sdl-wm-set-caption "TestCairo" "TestCairo")
(define s (sdl-set-video-mode maxx maxy 0 (+ SDL_HWSURFACE

(define is (cairo-image-surface-create-for-data
            (sdl-surface-pixels s)
            CAIRO_FORMAT_RGB24 maxx maxy
            (sdl-surface-pitch s)))

(define c (cairo-create is))

(define (draw-example c)
  (define (tri)
    (cairo-new-path c)
    (cairo-move-to c 110 110)
    (cairo-line-to c 110 190)
    (cairo-line-to c 190 190)
    (cairo-close-path c))

  (define (radians degrees)
    (* 3.142 (/ degrees 180)))

  (define (sector x y d)
    (cairo-new-path c)
    (cairo-move-to c x y)
    (cairo-line-to c (+ x d) y)
    (cairo-line-to c (+ x d) (+ y d))
    (cairo-arc c (+ x d) y d (radians 90) (radians 180)))

  (sdl-fill-rect s (make-sdl-rect 0 0 maxx maxy) (sdl-map-rgb 
(sdl-surface-pixel-format s) 0 0 0))

  (cairo-set-source-rgba c 1 1 0 1)

  (cairo-set-line-width c 20)

  (cairo-new-path c)
  (cairo-set-line-cap c CAIRO_LINE_CAP_BUTT)
  (cairo-move-to c 10 10)
  (cairo-line-to c 10 80)

  (cairo-stroke c)

  (cairo-new-path c)
  (cairo-set-line-cap c CAIRO_LINE_CAP_ROUND)
  (cairo-move-to c 50 10)
  (cairo-line-to c 50 80)
  (cairo-stroke c)

  (cairo-new-path c)
  (cairo-set-line-cap c CAIRO_LINE_CAP_SQUARE)
  (cairo-move-to c 90 10)
  (cairo-line-to c 90 80)
  (cairo-stroke c)

  (cairo-set-line-join c CAIRO_LINE_JOIN_BEVEL)

  (cairo-set-line-width c 10)
  (cairo-set-source-rgb c 0 1 1)
  (cairo-stroke c)
  (cairo-set-source-rgb c 1 0 1)
  (cairo-fill c)

  (sector 240 240 60)
  (cairo-set-line-join c CAIRO_LINE_JOIN_MITER)
  (cairo-set-source-rgb c 1 0.5 0)
  (cairo-stroke c)

  (cairo-reset-clip c)
  (cairo-new-path c)
  (cairo-rectangle c 30 240 70 300)
  (cairo-clip c)
  (cairo-new-path c)
  (sector 20 250 100)
  (cairo-set-source-rgb c 0 0.5 1)
  (cairo-fill c)

  (cairo-reset-clip c)
  (sector 20 250 100)
  (cairo-set-source-rgba c 0 0.5 1 0.3)
  (cairo-fill c)

  (cairo-select-font-face c "sans-serif" CAIRO_FONT_SLANT_NORMAL 
  (cairo-set-font-size c 30)

  (cairo-move-to c 300 100)
  (cairo-set-source-rgba c 1 1 1 1)
  (cairo-show-text c "Chicken Cairo")

  (let ((ext (make-cairo-text-extents-type)))
    (cairo-text-extents c "Chicken Cairo" ext)
                                        ;  (display ext)(newline)
    (cairo-new-path c)
    (cairo-rectangle c 300 100 (cairo-text-extents-width ext) (- 
(cairo-text-extents-height ext)))
    (cairo-set-source-rgba c 1 1 1 0.5)
    (cairo-set-line-width c 2.0)
    (cairo-stroke c)))

(draw-example c)
(sdl-flip s)

(let ((event (make-sdl-event))
      (last-pos '(0 . 0))
      (mouse-is-down #f))
  (let loop ()
    (sdl-wait-event! event)
    (let ((t (sdl-event-type event)))
      (cond ((= t SDL_MOUSEBUTTONDOWN)
             (set! last-pos `(,(sdl-event-x event) . ,(sdl-event-y event)))
             (set! mouse-is-down #t)
             (fmt #t "saved mouse pos " last-pos nl))
            ((= t SDL_MOUSEMOTION)
             (if mouse-is-down
                 (let* ((cur-x (sdl-event-x event))
                        (cur-y (sdl-event-y event))
                        (inc-x (- cur-x (car last-pos)))
                        (inc-y (- cur-y (cdr last-pos))))
                   (unless (and (eq? inc-x 0) (eq? inc-y 0))
                     (set! last-pos `(,cur-x . ,cur-y))
                     (fmt #t "transforming by " inc-x " " inc-y nl)
                     (cairo-translate c inc-x inc-y)
                     (draw-example c)
                     (sdl-flip s)))))
            ((= t SDL_MOUSEBUTTONUP)
             (set! mouse-is-down #f))
            ((= t SDL_QUIT)

(exit 0)

reply via email to

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