SDL Digest, Vol 12, Issue 32

Hi ,

I am new to sdl and I wish to work more with SDL
I have a requirement of Displaying multiple video Streams (16 nos)
in to a single Window with the overlay Support.
I am thinking in this way, because I believe creating multiple window
(Each window for each Video In Channels ) can not be supported with SDL,
As I failed.

I am creating 16 Threads in the main file , each for Each channel capture.
each thread will create its own overlay and display into diff. rectangle in
SDL Surface.

But this thread Creation end in Fail by giving X lib errors, I need
threading as the performance
w/o threading is Very Poor.
Please Share your ideas.
I get X lib errors as follows…

Open board… done.
Initialize board… done.
Set group slice controls… done.
press ESC to Quit.
Create capturing threads… 0 done.
Start capture video transfer…
0 *** glibc detected *** ./sample: free(): invalid pointer: 0xbf8242b8 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7c377cd]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7c3ae30]
/usr/lib/libSDL-1.2.so.0(SDL_WaitThread+0x44)[0xb7e29e44]
./sample[0x8049b02]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb7be5ebc]
./sample[0x8048fc1]
======= Memory map: ========
08048000-0804c000 r-xp 00000000 08:06 979674 /opt/Hicap/hicap_sdk/sample
0804c000-0804d000 rw-p 00003000 08:06 979674 /opt/Hicap/hicap_sdk/sample
0804d000-08e15000 rw-p 0804d000 00:00 0 [heap]
b54fb000-b54fc000 —p b54fb000 00:00 0
b54fc000-b5cfc000 rw-p b54fc000 00:00 0
b5cfc000-b5cfd000 —p b5cfc000 00:00 0
b5cfd000-b64fd000 rw-p b5cfd000 00:00 0
b65ca000-b65d5000 r-xp 00000000 08:06 1697344 /lib/libgcc_s.so.1
b65d5000-b65d6000 rw-p 0000a000 08:06 1697344 /lib/libgcc_s.so.1
b65d6000-b65d7000 —p b65d6000 00:00 0
b65d7000-b6dd7000 rw-p b65d7000 00:00 0
b6dd7000-b6dec000 rw-s 00000000 00:08 3244051 /SYSV00000000 (deleted)
b6dec000-b6df0000 r-xp 00000000 08:06 1437451 /usr/lib/libXfixes.so.3.1.0
b6df0000-b6df1000 rw-p 00003000 08:06 1437451 /usr/lib/libXfixes.so.3.1.0
b6df1000-b6df9000 r-xp 00000000 08:06 1437441
/usr/lib/libXcursor.so.1.0.2
b6df9000-b6dfa000 rw-p 00007000 08:06 1437441
/usr/lib/libXcursor.so.1.0.2
b6dfa000-b6dff000 r-xp 00000000 08:06 1437469 /usr/lib/libXrandr.so.2.1.0
b6dff000-b6e00000 rw-p 00005000 08:06 1437469 /usr/lib/libXrandr.so.2.1.0
b6e00000-b6e07000 r-xp 00000000 08:06 1437471
/usr/lib/libXrender.so.1.3.0
b6e07000-b6e08000 rw-p 00006000 08:06 1437471
/usr/lib/libXrender.so.1.3.0
b6e08000-b7a68000 rw-s 00000000 00:0d 13502 /dev/video0
b7a68000-b7a6a000 rw-p b7a68000 00:00 0
b7a6a000-b7a6e000 r-xp 00000000 08:06 1437445 /usr/lib/libXdmcp.so.6.0.0
b7a6e000-b7a6f000 rw-p 00003000 08:06 1437445 /usr/lib/libXdmcp.so.6.0.0
b7a6f000-b7a71000 r-xp 00000000 08:06 1437434 /usr/lib/libXau.so.6.0.0
b7a71000-b7a72000 rw-p 00001000 08:06 1437434 /usr/lib/libXau.so.6.0.0
b7a72000-b7a73000 rw-p b7a72000 00:00 0
b7a73000-b7a81000 r-xp 00000000 08:06 1437584 /usr/lib/libdirect-
0.9.so.25.0.0
b7a81000-b7a82000 rw-p 0000e000 08:06 1437584 /usr/lib/libdirect-
0.9.so.25.0.0
b7a82000-b7a87000 r-xp 00000000 08:06 1437652 /usr/lib/libfusion-
0.9.so.25.0.0
b7a87000-b7a88000 rw-p 00004000 08:06 1437652 /usr/lib/libfusion-
0.9.so.25.0.0
b7a88000-b7add000 r-xp 00000000 08:06 1437586 /usr/lib/libdirectfb-
0.9.so.25.0.0
b7add000-b7adf000 rw-p 00055000 08:06 1437586 /usr/lib/libdirectfb-
0.9.so.25.0.0
b7adf000-b7ae1000 r-xp 00000000 08:06 1731208 /lib/tls/i686/cmov/libdl-
2.5.so
b7ae1000-b7ae3000 rw-p 00001000 08:06 1731208 /lib/tls/i686/cmov/libdl-
2.5.so
b7ae3000-b7b08000 r-xp 00000000 08:06 1731210 /lib/tls/i686/cmov/libm-
2.5.so
b7b08000-b7b0a000 rw-p 00024000 08:06 1731210 /lib/tls/i686/cmov/libm-
2.5.so
b7b0a000-b7bca000 r-xp 00000000 08:06 1437499 /usr/lib/libasound.so.2.0.0
b7bca000-b7bcf000 rw-p 000bf000 08:06 1437499 /usr/lib/libasound.so.2.0.0
b7bcf000-b7bd0000 rw-p b7bcf000 00:00 0
b7bd0000-b7d0b000 r-xp 00000000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0b000-b7d0c000 r–p 0013b000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0c000-b7d0e000 rw-p 0013c000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0e000-b7d11000 rw-p b7d0e000 00:00 0
b7d11000-b7d15000 r-xp 00000000 08:06 1437485
/usr/lib/libXxf86vm.so.1.0.0
b7d15000-b7d16000 rw-p 00003000 08:06 1437485
/usr/lib/libXxf86vm.so.1.0.0
b7d16000-b7d1a000 r-xp 00000000 08:06 1437481
/usr/lib/libXxf86dga.so.1.0.0
b7d1a000-b7d1b000 rw-p 00004000 08:06 1437481
/usr/lib/libXxf86dga.so.1.0.0
b7d1b000-b7e08000 r-xp 00000000 08:06 1437428 /usr/lib/libX11.so.6.2.0
b7e08000-b7e0c000 rw-p 000ed000 08:06 1437428 /usr/lib/libX11.so.6.2.0
b7e0c000-b7e19000 r-xp 00000000 08:06 1437449 /usr/lib/libXext.so.6.4.0
b7e19000-b7e1a000 rw-p 0000d000 08:06 1437449 /usr/lib/libXext.so.6.4.0
b7e1a000-bAborted (core dumped)#####

renjith kumar wrote:

*** glibc detected *** ./sample: free(): invalid pointer: 0xbf8242b8 ***

I get this same error when my program exits. I’ve been ignoring it
because I thought maybe SDL_FreeSurface (or some other sdl free
function) was getting called more than once for the same pointer.

jim

James Barrett wrote:

renjith kumar wrote:

*** glibc detected *** ./sample: free(): invalid pointer:
0xbf8242b8 ***

I get this same error when my program exits. I’ve been ignoring it
because I thought maybe SDL_FreeSurface (or some other sdl free
function) was getting called more than once for the same pointer.

ignoring it is not very good practice, you have a bug in your code that
might come back at some later time and bite you.

i suggest the usage of valgrind (for both of you).

best regards …
clemens

The tool reports a LOT of memory leaks and errors in libsdl. How
accurate is this tool?
Does this tool report deleting a null pointer as an error? Looks like it
might be even though it shouldn’t, but I’m having a hard time reading
through all of the output.

Clemens Kirchgatterer wrote:> James Barrett <@James_Barrett> wrote:

renjith kumar wrote:

*** glibc detected *** ./sample: free(): invalid pointer:
0xbf8242b8 ***

I get this same error when my program exits. I’ve been ignoring it
because I thought maybe SDL_FreeSurface (or some other sdl free
function) was getting called more than once for the same pointer.

ignoring it is not very good practice, you have a bug in your code that
might come back at some later time and bite you.

i suggest the usage of valgrind (for both of you).

best regards …
clemens

The tool reports a LOT of memory leaks and errors in libsdl.

Yeah… There are a lot of such issues in various libs, including
the system libs, and Valgrind will trap them all. It seems like every
system needs a massive suppression config to filter that noise out.

If you install Valgrind as a distro specific package, it may come with
at least some suppression rules for the system libs that come with
the distro.

How accurate is this tool?

Very, in my experience. Valgrind is running the code in VM (ie
emulating the CPU) in order to trap things the hardware memory
management can’t handle, and it also keeps track of where memory
blocks were allocated, freed etc, to generate more useful output.

Does this tool report deleting a null pointer as an error?

It shouldn’t, I think… Never seen it.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Wednesday 26 December 2007, James Barrett wrote: