Hi,
For the past few weeks I've been playing with Common Lisp, and tried
to make a simple wrapper for libggi, so that I can play with graphics
in it. One doesn't exit a lisp session usually, so opening and
closing visuals again and again is common.
I was used to writing small programs in C that open a visual once, and
then close it. Now, I'm running into some problems.
The following code should work imho:
------begin snippet------
#include <ggi/ggi.h>
int main()
{
ggi_visual_t vis;
ggiInit ();
vis = ggiOpen ( NULL );
ggiSetGraphMode ( vis, 320, 200, 320, 200, GT_8BIT );
ggiClose ( vis );
/* mark #1 */
vis = ggiOpen ( NULL );
ggiSetGraphMode ( vis, 320, 200, 320, 200, GT_8BIT );
ggiClose ( vis );
ggiExit ();
return 0;
}
------end snippet------
However, this doesn't work for me in X11 nor in Svgalib. In X11 it
locks up after the first screen is closed. In Svgalib it locks up
after two mode switches.
I had to add the following two lines at 'mark #1', to make it work in
X11:
ggiExit ();
ggiInit ();
Seems awkward to me that this is the right solution. And it doesn't
fix the problem in Svgalib, where it exits with a segfault.
Opening and closing ONE visual works great. No problem with svgalib
nor X11. I've started debugging a little but got hopelessly lost and
thought it might be wiser to post here first..
I'm using a ggi snapshot of April 1st, and there hasn't changed one
line of code in the svgalib nor x11 wrappers since.
The version of svgalib used is 1.9.2, which is great.
Here's the debug output for an svgalib run of the program with the
ggiExit() and ggiInit() in place:
LibGII: Debugging=255
LibGGI: Debugging=255
LibGGI: ggiOpen("svga") called
LibGGI: Loading driver svga
LibGGI: _ggiAddDL(0x804ba38, "svga", "(null)", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/display/svgalib.so", 0x1) called
LibGGI: hand.handle=0x804bd88
LibGGI: hand.init=0x401097c4
LibGGI: hand.cleanup=0x40109d14
LibGGI: _ggiLoadDL returned 0x804c5f8
LibGGI: _ggiAddDL(0x804ba38, "helper-linux-vtswitch", "(null)", 0x0) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/display/lin_vtsw.so", 0x0) called
LibGGI: hand.handle=0x805c998
LibGGI: hand.init=0x402b79fc
LibGGI: hand.cleanup=0x402b7bd8
LibGGI: _ggiLoadDL returned 0x805cc00
LibGGI: L/vtswitch: GGIdlinit(0x804ba38,...) called
LibGGI: L/vtswitch: have private mutex
LibGGI: L/vtswitch: Using VT 8.
LibGGI: L/vtswitch: open OK.
LibGGI: 0 = dlh->init(0x804ba38,"(null)",0xbfffe714) - helper-linux-vtswitch
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x805ccb0) called
LibGII: Got queue_set: 0x805ce38
LibGII: giiOpen adding "linux-kbd", "/dev/tty8", (nil)
LibGII: _giiLoadDL("linux-kbd","(NULL)") called
LibGII: hand.handle=0x805ceb8
LibGII: hand.init=0x402bb8b8
LibGII: _giiLoadDL returned 0x805d1c8
LibGII: linux_kbd starting.(args="/dev/tty8",argptr=(nil))
LibGII: Linux-kbd: opening tty
LibGII: Linux-kbd: calling tcgetattr()
LibGII: Linux-kbd: calling tcsetattr()
LibGII: Linux-kbd: going to MEDIUMRAW mode
LibGII: Linux-kbd: init OK.
LibGII: _giiEvQueueAdd(0x805ccb0, 0xbfffd66c) called
LibGII: _giiEvQueueSetup alloced 0x805d9e0
LibGII: Adding event type 1, size 116 at pos 0
LibGII: linux_kbd fully up
LibGII: 0=dlh->init(0x805ccb0,"/dev/tty8",(nil)) - linux-kbd
LibGII: _giiUpdateCache(0x805ccb0) called
LibGII: Found fd: 7
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x805f9f0) called
LibGII: Got queue_set: 0x805fb78
LibGII: giiOpen adding "linux-mouse", "auto", 0xbfffe758
LibGII: _giiLoadDL("linux-mouse","(NULL)") called
LibGII: hand.handle=0x805fbf8
LibGII: hand.init=0x402bfe20
LibGII: _giiLoadDL returned 0x805ff18
LibGII: linux_mouse starting.(args="auto",argptr=0xbfffe758)
LibGII: linux_mouse: prot=`Microsoft' dev=`/dev/mouse' opts=`'
LibGII: linux-mouse: Opened mouse file '/dev/mouse' ReadOnly.
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x805ff78) called
LibGII: Got queue_set: 0x8060100
LibGII: giiOpen adding "input-mouse", "10,ms", (nil)
LibGII: _giiLoadDL("input-mouse","(NULL)") called
LibGII: hand.handle=0x8060178
LibGII: hand.init=0x402c2d70
LibGII: _giiLoadDL returned 0x8060478
LibGII: _giiEvQueueAdd(0x805ff78, 0xbfffcd7c) called
LibGII: _giiEvQueueSetup alloced 0x8060530
LibGII: Adding event type 1, size 116 at pos 0
LibGII: mouse fully up
LibGII: 0=dlh->init(0x805ff78,"10,ms",(nil)) - input-mouse
LibGII: _giiUpdateCache(0x805ff78) called
LibGII: Found fd: 10
LibGII: giiJoinInputs(0x805f9f0, 0x805ff78) called
LibGII: giiEventPoll(0x805ff78, 0x3ffe, 0xbfffd214) called
LibGII: Fetching event from 0x805ff78
LibGII: _giiEvQueueRelease(0x805ff78, 0xbfffd21c, 0x3ffe) called
LibGII: Retrieved event type 1, size 116.
LibGII: Storing event in 0x805f9f0
LibGII: _giiEvQueueAdd(0x805f9f0, 0xbfffd21c) called
LibGII: _giiEvQueueSetup alloced 0x8062540
LibGII: Adding event type 1, size 116 at pos 0
LibGII: giiEventPoll(0x805ff78, 0x3ffe, 0xbfffd214) called
LibGII: _giiPollAll(0x805ff78, 0x3ffe, (nil)) called
LibGII: GII_mouse_poll(0x805ff78, (nil)) called
LibGII: GII_mouse_poll: done
LibGII: _giiEvQueueDestroy(0x805ff78) called
LibGII: Destroying 0x8060100, 0x8060104
LibGII: _giiEvQueueDestroy done
LibGII: _giiSetQueue(0x805ff78, 0x805f9f0) called
LibGII: _giiUpdateCache(0x805f9f0) called
LibGII: Found fd: 10
LibGII: linux_mouse fully up
LibGII: 0=dlh->init(0x805f9f0,"auto",0xbfffe758) - linux-mouse
LibGII: _giiUpdateCache(0x805f9f0) called
LibGII: Found fd: 10
LibGII: giiJoinInputs(0x805ccb0, 0x805f9f0) called
LibGII: giiEventPoll(0x805f9f0, 0x3ffe, 0xbfffdb34) called
LibGII: Fetching event from 0x805f9f0
LibGII: _giiEvQueueRelease(0x805f9f0, 0xbfffdb3c, 0x3ffe) called
LibGII: Retrieved event type 1, size 116.
LibGII: Storing event in 0x805ccb0
LibGII: _giiEvQueueAdd(0x805ccb0, 0xbfffdb3c) called
LibGII: Adding event type 1, size 116 at pos 1
LibGII: giiEventPoll(0x805f9f0, 0x3ffe, 0xbfffdb34) called
LibGII: _giiPollAll(0x805f9f0, 0x3ffe, (nil)) called
LibGII: GII_mouse_poll(0x805ff78, (nil)) called
LibGII: GII_mouse_poll: done
LibGII: _giiEvQueueDestroy(0x805f9f0) called
LibGII: Destroying 0x805fb78, 0x805fb7c
LibGII: _giiEvQueueDestroy done
LibGII: _giiSetQueue(0x805f9f0, 0x805ccb0) called
LibGII: _giiUpdateCache(0x805ccb0) called
LibGII: Found fd: 7
LibGII: Found fd: 10
LibGGI: 1 = dlh->init(0x804ba38,"(null)",(nil)) - svga
LibGGI: ggiOpen: returning 0x804ba38
LibGGI: Loading extra inputs/filters for svga
LibGGI: Checking GGI_INPUT_SVGA_1 : (nil)
LibGGI: Checking GGI_INPUT_SVGA : (nil)
LibGGI: Checking GGI_INPUT : (nil)
LibGGI: ggiSetGraphMode(0x804ba38, 320, 200, 320, 200, 0x4000808) called
LibGGI: ggiSetMode(0x804ba38, 320x200.V320x200.[P8/8]) called
LibGGI: ggiSetMode: trying (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: trying2 (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: calling 0x401086b0
LibGGI: Setting SVGAlib mode 5: G320x200x256
LibGGI: _ggiAddDL(0x804ba38, "generic-stubs", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/stubs.so", 0x1) called
LibGGI: hand.handle=0x8061940
LibGGI: hand.init=0x402c8db0
LibGGI: hand.cleanup=0x402c8fec
LibGGI: _ggiLoadDL returned 0x805fb68
LibGGI: 4 = dlh->init(0x804ba38,"",(nil)) - generic-stubs
LibGGI: Success in loading generic-stubs ()
LibGGI: _ggiAddDL(0x804ba38, "generic-color", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/color.so", 0x1) called
LibGGI: hand.handle=0x8061b98
LibGGI: hand.init=0x402cc968
LibGGI: hand.cleanup=0x402ccb14
LibGGI: _ggiLoadDL returned 0x8061ec8
LibGGI: 2 = dlh->init(0x804ba38,"",(nil)) - generic-color
LibGGI: Success in loading generic-color ()
LibGGI: _ggiAddDL(0x804ba38, "generic-linear-8", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/linear_8.so", 0x1) called
LibGGI: hand.handle=0x8061f60
LibGGI: hand.init=0x402d0e10
LibGGI: hand.cleanup=0x402d0f8c
LibGGI: _ggiLoadDL returned 0x8062280
LibGGI: 4 = dlh->init(0x804ba38,"",(nil)) - generic-linear-8
LibGGI: Success in loading generic-linear-8 ()
LibGGI: ggiIndicateChange(0x804ba38, 0x1) called
LibGGI: ggiIndicateChange: 1 changed for 0x804ba38.
LibGGI: ggiSetMode: set to frame 0, origin = {0,0}
LibGGI: _default_error() called
LibGGI: _default_error() called
LibGGI: ggiSetMode: set GC
LibGGI: ggiSetMode: success (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: SetWriteFrame 0
LibGGI: ggiSetMode: frame address: 0x4017d000
LibGGI: ggiSetMode: FillScreen 0
LibGGI: ggiSetMode: done!
LibGGI: ggiClose("0x804ba38") called
LibGGI: ggiClose: closing
LibGII: giiClose(0x805ccb0) called
LibGII: _giiEvQueueDestroy(0x805ccb0) called
LibGII: Destroying 0x805ce38, 0x805ce3c
LibGII: _giiEvQueueDestroy done
LibGII: Linux-kbd cleanup
LibGII: Linux-kbd: exit OK.
LibGII: linux_mouse cleanup
LibGII: linux_mouse: exit OK.
LibGGI: _ggiZapDL(0x804ba38, 0x804bc34) called
LibGGI: Disposing "generic-linear-8"
LibGGI: Closing handle: 0x8061f60
LibGGI: Disposing "generic-stubs"
LibGGI: Closing handle: 0x8061940
LibGGI: _ggiZapDL(0x804ba38, 0x804b634) called
LibGGI: Disposing "generic-color"
LibGGI: Closing handle: 0x8061b98
LibGGI: _ggiZapDL(0x804ba38, 0x804bd24) called
LibGGI: Disposing "svga"
LibGGI: Closing handle: 0x804bd88
LibGGI: _ggiZapDL(0x804ba38, 0x804baf0) called
LibGGI: Disposing "helper-linux-vtswitch"
LibGGI: L/vtswitch: close OK.
LibGGI: Closing handle: 0x805c998
LibGGI: ggiClose: done!
LibGGI: ggiExit called
LibGGI: ggiExit: really destroying.
LibGII: giiExit() called
LibGII: giiExit: really destroying.
LibGII: giiExit: done!
LibGGI: ggiExit: done!
LibGII: Debugging=255
LibGGI: Debugging=255
LibGGI: ggiOpen("svga") called
LibGGI: Loading driver svga
LibGGI: _ggiAddDL(0x804b4e0, "svga", "(null)", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/display/svgalib.so", 0x1) called
LibGGI: hand.handle=0x804b948
LibGGI: hand.init=0x401097c4
LibGGI: hand.cleanup=0x40109d14
LibGGI: _ggiLoadDL returned 0x804c210
LibGGI: _ggiAddDL(0x804b4e0, "helper-linux-vtswitch", "(null)", 0x0) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/display/lin_vtsw.so", 0x0) called
LibGGI: hand.handle=0x805cde0
LibGGI: hand.init=0x403f09fc
LibGGI: hand.cleanup=0x403f0bd8
LibGGI: _ggiLoadDL returned 0x805d0c0
LibGGI: L/vtswitch: GGIdlinit(0x804b4e0,...) called
LibGGI: L/vtswitch: have private mutex
LibGGI: L/vtswitch: Using VT 8.
LibGGI: L/vtswitch: open OK.
LibGGI: 0 = dlh->init(0x804b4e0,"(null)",0xbfffe714) - helper-linux-vtswitch
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x805d170) called
LibGII: Got queue_set: 0x805d2f8
LibGII: giiOpen adding "linux-kbd", "/dev/tty8", (nil)
LibGII: _giiLoadDL("linux-kbd","(NULL)") called
LibGII: hand.handle=0x805d378
LibGII: hand.init=0x403f48b8
LibGII: _giiLoadDL returned 0x805d688
LibGII: linux_kbd starting.(args="/dev/tty8",argptr=(nil))
LibGII: Linux-kbd: opening tty
LibGII: Linux-kbd: calling tcgetattr()
LibGII: Linux-kbd: calling tcsetattr()
LibGII: Linux-kbd: going to MEDIUMRAW mode
LibGII: Linux-kbd: init OK.
LibGII: _giiEvQueueAdd(0x805d170, 0xbfffd66c) called
LibGII: _giiEvQueueSetup alloced 0x805dea0
LibGII: Adding event type 1, size 116 at pos 0
LibGII: linux_kbd fully up
LibGII: 0=dlh->init(0x805d170,"/dev/tty8",(nil)) - linux-kbd
LibGII: _giiUpdateCache(0x805d170) called
LibGII: Found fd: 8
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x805feb0) called
LibGII: Got queue_set: 0x8060038
LibGII: giiOpen adding "linux-mouse", "auto", 0xbfffe758
LibGII: _giiLoadDL("linux-mouse","(NULL)") called
LibGII: hand.handle=0x80600b8
LibGII: hand.init=0x403f8e20
LibGII: _giiLoadDL returned 0x80603d8
LibGII: linux_mouse starting.(args="auto",argptr=0xbfffe758)
LibGII: linux_mouse: prot=`Microsoft' dev=`/dev/mouse' opts=`'
LibGII: linux-mouse: Opened mouse file '/dev/mouse' ReadOnly.
LibGII: Allocating input structure
LibGII: _giiEvQueueAllocate(0x804c2c8) called
LibGII: Got queue_set: 0x8060438
LibGII: giiOpen adding "input-mouse", "11,ms", (nil)
LibGII: _giiLoadDL("input-mouse","(NULL)") called
LibGII: hand.handle=0x8070538
LibGII: hand.init=0x403fbd70
LibGII: _giiLoadDL returned 0x804c4b8
LibGII: _giiEvQueueAdd(0x804c2c8, 0xbfffcd7c) called
LibGII: _giiEvQueueSetup alloced 0x8070768
LibGII: Adding event type 1, size 116 at pos 0
LibGII: mouse fully up
LibGII: 0=dlh->init(0x804c2c8,"11,ms",(nil)) - input-mouse
LibGII: _giiUpdateCache(0x804c2c8) called
LibGII: Found fd: 11
LibGII: giiJoinInputs(0x805feb0, 0x804c2c8) called
LibGII: giiEventPoll(0x804c2c8, 0x3ffe, 0xbfffd214) called
LibGII: Fetching event from 0x804c2c8
LibGII: _giiEvQueueRelease(0x804c2c8, 0xbfffd21c, 0x3ffe) called
LibGII: Retrieved event type 1, size 116.
LibGII: Storing event in 0x805feb0
LibGII: _giiEvQueueAdd(0x805feb0, 0xbfffd21c) called
LibGII: _giiEvQueueSetup alloced 0x8072778
LibGII: Adding event type 1, size 116 at pos 0
LibGII: giiEventPoll(0x804c2c8, 0x3ffe, 0xbfffd214) called
LibGII: _giiPollAll(0x804c2c8, 0x3ffe, (nil)) called
LibGII: GII_mouse_poll(0x804c2c8, (nil)) called
LibGII: GII_mouse_poll: done
LibGII: _giiEvQueueDestroy(0x804c2c8) called
LibGII: Destroying 0x8060438, 0x806043c
LibGII: _giiEvQueueDestroy done
LibGII: _giiSetQueue(0x804c2c8, 0x805feb0) called
LibGII: _giiUpdateCache(0x805feb0) called
LibGII: Found fd: 11
LibGII: linux_mouse fully up
LibGII: 0=dlh->init(0x805feb0,"auto",0xbfffe758) - linux-mouse
LibGII: _giiUpdateCache(0x805feb0) called
LibGII: Found fd: 11
LibGII: giiJoinInputs(0x805d170, 0x805feb0) called
LibGII: giiEventPoll(0x805feb0, 0x3ffe, 0xbfffdb34) called
LibGII: Fetching event from 0x805feb0
LibGII: _giiEvQueueRelease(0x805feb0, 0xbfffdb3c, 0x3ffe) called
LibGII: Retrieved event type 1, size 116.
LibGII: Storing event in 0x805d170
LibGII: _giiEvQueueAdd(0x805d170, 0xbfffdb3c) called
LibGII: Adding event type 1, size 116 at pos 1
LibGII: giiEventPoll(0x805feb0, 0x3ffe, 0xbfffdb34) called
LibGII: _giiPollAll(0x805feb0, 0x3ffe, (nil)) called
LibGII: GII_mouse_poll(0x804c2c8, (nil)) called
LibGII: _giiEvQueueDestroy(0x805feb0) called
LibGII: Destroying 0x8060038, 0x806003c
LibGII: _giiEvQueueDestroy done
LibGII: _giiSetQueue(0x805feb0, 0x805d170) called
LibGII: _giiUpdateCache(0x805d170) called
LibGII: Found fd: 8
LibGII: Found fd: 11
LibGGI: 1 = dlh->init(0x804b4e0,"(null)",(nil)) - svga
LibGGI: ggiOpen: returning 0x804b4e0
LibGGI: Loading extra inputs/filters for svga
LibGGI: Checking GGI_INPUT_SVGA_2 : (nil)
LibGGI: Checking GGI_INPUT_SVGA : (nil)
LibGGI: Checking GGI_INPUT : (nil)
LibGGI: ggiSetGraphMode(0x804b4e0, 320, 200, 320, 200, 0x4000808) called
LibGGI: ggiSetMode(0x804b4e0, 320x200.V320x200.[P8/8]) called
LibGGI: ggiSetMode: trying (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: trying2 (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: calling 0x401086b0
LibGGI: Setting SVGAlib mode 5: G320x200x256
LibGGI: _ggiAddDL(0x804b4e0, "generic-stubs", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/stubs.so", 0x1) called
LibGGI: hand.handle=0x8071b78
LibGGI: hand.init=0x40401db0
LibGGI: hand.cleanup=0x40401fec
LibGGI: _ggiLoadDL returned 0x804c440
LibGGI: 4 = dlh->init(0x804b4e0,"",(nil)) - generic-stubs
LibGGI: Success in loading generic-stubs ()
LibGGI: _ggiAddDL(0x804b4e0, "generic-color", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/color.so", 0x1) called
LibGGI: hand.handle=0x8071da8
LibGGI: hand.init=0x40405968
LibGGI: hand.cleanup=0x40405b14
LibGGI: _ggiLoadDL returned 0x8060060
LibGGI: 2 = dlh->init(0x804b4e0,"",(nil)) - generic-color
LibGGI: Success in loading generic-color ()
LibGGI: _ggiAddDL(0x804b4e0, "generic-linear-8", "", 0x1) called
LibGGI: _ggiLoadDL("/usr/lib/ggi/default/linear_8.so", 0x1) called
LibGGI: hand.handle=0x80720d0
LibGGI: hand.init=0x40409e10
LibGGI: hand.cleanup=0x40409f8c
LibGGI: _ggiLoadDL returned 0x80723f0
LibGGI: 4 = dlh->init(0x804b4e0,"",(nil)) - generic-linear-8
LibGGI: Success in loading generic-linear-8 ()
LibGGI: ggiIndicateChange(0x804b4e0, 0x1) called
LibGGI: ggiIndicateChange: 1 changed for 0x804b4e0.
LibGGI: ggiSetMode: set to frame 0, origin = {0,0}
LibGGI: _default_error() called
LibGGI: _default_error() called
LibGGI: ggiSetMode: set GC
LibGGI: ggiSetMode: success (vis 320x200 virt 320x200)
LibGGI: ggiSetMode: SetWriteFrame 0
LibGGI: ggiSetMode: frame address: 0x402b6000
LibGGI: ggiSetMode: FillScreen 0
LibGGI: ggiSetMode: done!
LibGGI: ggiClose("0x804b4e0") called
LibGGI: ggiClose: closing
LibGII: giiClose(0x805d170) called
LibGII: _giiEvQueueDestroy(0x805d170) called
LibGII: Destroying 0x805d2f8, 0x805d2fc
LibGII: _giiEvQueueDestroy done
LibGII: Linux-kbd cleanup
LibGII: Linux-kbd: exit OK.
LibGII: linux_mouse cleanup
LibGII: linux_mouse: exit OK.
LibGGI: _ggiZapDL(0x804b4e0, 0x804b73c) called
LibGGI: Disposing "generic-linear-8"
LibGGI: Closing handle: 0x80720d0
LibGGI: Disposing "generic-stubs"
LibGGI: Closing handle: 0x8071b78
LibGGI: _ggiZapDL(0x804b4e0, 0x804b82c) called
LibGGI: Disposing "generic-color"
LibGGI: Closing handle: 0x8071da8
LibGGI: _ggiZapDL(0x804b4e0, 0x804b8bc) called
LibGGI: Disposing "svga"
LibGGI: Closing handle: 0x804b948
LibGGI: _ggiZapDL(0x804b4e0, 0x804b598) called
LibGGI: Disposing "helper-linux-vtswitch"
LibGGI: L/vtswitch: close OK.
LibGGI: Closing handle: 0x805cde0
LibGGI: ggiClose: done!
LibGGI: ggiExit called
LibGGI: ggiExit: really destroying.
LibGII: giiExit() called
LibGII: giiExit: really destroying.
LibGII: giiExit: done!
LibGGI: ggiExit: done!
Segmentation fault
Hopefully anyone can help me out..
Do I really need the ggiExit() and ggiInit() ?
Thanks,
--
Tijs van Bakel, <[EMAIL PROTECTED]>