Discussion:
[directfb-users] Segmentation fault, while running directfb
Amaresh Kotekal
2012-07-30 13:55:22 UTC
Permalink
Dear All,

My name is Amaresh. I am working as a junior engineer in Altech UEC on STB
domain from past 6 months. I am very much interested to learn directfb.

I have installed directfb library on my virtual machine fedora 12.

I am trying to load sample png image and display it.

i got the following code from the net sample2.c

#include <directfb.h>
#include <unistd.h>

IDirectFB *dfb;
IDirectFBSurface *primary;
IDirectFBImageProvider *provider;

DFBSurfaceDescription dsc;

int main(int argc, char *argv[])
{
DirectFBInit(&argc, &argv);
DirectFBCreate(&dfb);

dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN);

/* Primary */
memset(&dsc, 0, sizeof(DFBSurfaceDescription));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY;
dfb->CreateSurface(dfb, &dsc, &primary);

/* Background */

dfb->CreateImageProvider(dfb, "/home/amaresh/hello/sample.png",
&provider);
provider->RenderTo(provider, primary, NULL);
provider->Release(provider);

sleep(5);

primary->Release(primary);
dfb->Release(dfb);
return 0;
}

i have compiled using below command

# cc sample2.c -I /usr/include/directfb/ /usr/local/lib/libdirectfb-1.7.so.0

# ./a.out

~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.7.0 |~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) 2001-2012 The world wide DirectFB Open Source Community
(c) 2000-2004 Convergence (integrated media) GmbH
----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2012-07-20 14:33)
(*) Direct/Thread: Started 'Fusion Dispatch' (1928) [MESSAGING OTHER/OTHER
0/0] <10485760>...
(*) Direct/Thread: Started 'VT Switcher' (1931) [CRITICAL OTHER/OTHER 0/0]
<10485760>...
(*) Direct/Thread: Started 'VT Flusher' (1932) [DEFAULT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/FBDev: Found 'VESA VGA' (ID 0) with frame buffer at
0xd0000000, 3600k (MMIO 0x00000000, 0k)
(*) Direct/Thread: Started 'Linux Input' (1933) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: Power Button (1) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (1934) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: Macintosh mouse button emulatio (2) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (1935) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: AT Translated Set 2 keyboard (3) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (1936) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: ImPS/2 Generic Wheel Mouse (4) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Hotplug with Linux Input' (1937) [INPUT
OTHER/OTHER 0/0] <10485760>...
(*) DirectFB/Input: Hot-plug detection enabled with Linux Input Driver
(*) Direct/Thread: Started 'PS/2 Input' (1938) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: IMPS/2 Mouse 1.0 (directfb.org)
(*) DirectFB/Input: Hot-plug detection enabled with Input Hub Driver
(*) Direct/Thread: Started 'Keyboard Input' (1939) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: Keyboard 0.9 (directfb.org)
(*) DirectFB/Genefx: MMX detected and enabled
(*) DirectFB/Graphics: MMX Software Rasterizer 0.7 (directfb.org)
(*) DirectFB/Core/WM: Default 0.3 (directfb.org)
(*) FBDev/Mode: Setting 1280x720 RGB16
(*) FBDev/Mode: Switched to 1280x720 (virtual 1280x720) at 16 bit (RGB16),
pitch 2560
(*) FBDev/Mode: Setting 1280x720 RGB16
(*) FBDev/Mode: Switched to 1280x720 (virtual 1280x720) at 16 bit (RGB16),
pitch 2560
Segmentation fault (core dumped)

I am getting segmentation fault while running .exe file.

First three times it ran successfully and displayed the image.

Could you guys help me please ?

If you guys have a any documents on directfb, please send me.

Thanks in advance

Regards,
Amaresh
Ezequiel Garcia
2012-07-30 14:59:43 UTC
Permalink
On Mon, Jul 30, 2012 at 10:55 AM, Amaresh Kotekal
Post by Amaresh Kotekal
My name is Amaresh. I am working as a junior engineer in Altech UEC on STB
domain from past 6 months. I am very much interested to learn directfb.
I have installed directfb library on my virtual machine fedora 12.
I am trying to load sample png image and display it.
Hi Amaresh,

Mmmm, you are not checking *any* errors and every DFB function returns
an error code.

I'm sure you know this is *very* bad practice, and this could explain
your core dump (or maybe not).

Plus, to find your segfault you can add a printf between each DFB
call. Have you done that?

For documentation you can read this

http://directfb.org/docs/DirectFB_Reference_1_6/index.html

(it's not much, but that's all there is)

Also, perhaps you can find useful my Lua binding to DirectFB.
It includes many examples and it is easier to use, for quick testing.

https://github.com/ezequielgarcia/directfb-lua

Hope it helps and good luck,
Ezequiel.

Loading...