Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-other / 2006-06

SDL TimerCallback crash with Linux

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi there,

I am developing a small game with FreePascal (FP for short) and SDL. While trying to support multiple platforms I ran into a problem with SDL_AddTimer. I reduced my code to the core problem (see below) to find out what's wrong.

In Win32 the executables (FP and C) run as expected. But when I compile the same code under Linux only the C binary will run while the FP binary crashes at the first call to the timer callback function:

Starting...
SDL_AddTimer: Success!
Waiting 8 seconds...
An unhandled exception occurred at $08055A31 :
Exception : Unknown Run-Time error : 202
$08055A31
$08048472
$40036544
$4006638A
$4003615B
$400638CF
$400B9E51

I am using FreePascal 2.0.2 with SDL 1.2.10 (i.e. libSDL-1.2.so.0.7.3) on Debian. Using JEDI-SDLv1.0 or SDL4FreePascal leads to same crash.

Any help appreciated.

Sascha

//------------------------------------------------------------------------------
// C code
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include "SDL/SDL.h"

Uint32 timer_func(Uint32 interval, void *parameter) {

  printf ("timer interval: %d ms\n", interval);
  return (interval-1000);

}

int main (void)
{

  SDL_TimerID MyTimer;
  printf("Starting...\n");
  if (SDL_Init(SDL_INIT_TIMER) < 0)
  {
      printf("Kann SDL nicht initialisieren: %s\n", SDL_GetError());
      exit(1);
  }
  atexit(SDL_Quit);
  // Now add timer
  MyTimer = SDL_AddTimer(3000, timer_func, NULL);
  if (MyTimer == NULL)
  {
      printf("SDL_AddTimer: Error!\n");
      exit(1);
  }
  atexit(SDL_Quit);
  printf ("SDL_AddTimer: Success!\n");
  // just wait
  printf("Waiting 8 seconds...\n");
  SDL_Delay( 8000 );
  // Release
  SDL_Quit;
  printf("ByeBye ;)\n");
  return(0);
}
//------------------------------------------------------------------------------
// PASCAL code
//------------------------------------------------------------------------------
program timer;
{$mode objfpc}

uses
sysutils,
sdl_timer, sdl_types, // SDL4FP //

  sdl;
var
  //JEDI//_Timer: PSDL_TimerID;
  _Timer: SDL_TimerID; // SDL4FP //
function timer_func(Interval: Uint32; Param: Pointer): Uint32; cdecl;
begin
  Writeln('timer interval: ' + IntToStr(Interval) + ' ms');
  Result := Interval-1000;
end;
begin
  Writeln('Starting...');
  // Init SDL and timer
  if SDL_Init(SDL_INIT_TIMER) < 0 then
  begin
    Writeln('SDL_Init: Error!');
    Exit;
  end;
  // Now add timer
  _Timer := SDL_AddTimer( 3000, @timer_func, nil );
  if _Timer = nil then
  begin
    Writeln('SDL_AddTimer: Error!');
    Exit;
  end;
  Writeln('SDL_AddTimer: Success!');
  // just wait
  Writeln('Waiting 8 seconds...');
  SDL_Delay( 8 * 1000 );
  // Release
  SDL_Quit;
  WriteLn('ByeBye ;)');
end.

Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr!
http://www.arcor.de/rd/emf-dsl-2

Geno Roupsky
to Unknown author

2006/6/1, :

Show quoted text 27 lines
Hi there, I am developing a small game with FreePascal (FP for short) and SDL. While trying to support multiple platforms I ran into a problem with SDL_AddTimer. I reduced my code to the core problem (see below) to find out what's wrong. In Win32 the executables (FP and C) run as expected. But when I compile the same code under Linux only the C binary will run while the FP binary crashes at the first call to the timer callback function: Starting... SDL_AddTimer: Success! Waiting 8 seconds... An unhandled exception occurred at $08055A31 : Exception : Unknown Run-Time error : 202 $08055A31 $08048472 $40036544 $4006638A $4003615B $400638CF $400B9E51 My guess is that it has to do with the calling conventions but I don't see

why and can't test right now. Try compiling with -gl to see line numbers in the back trace.

Geno Roupsky
Unknown author
to Unknown author: I am developing a small game with FreePascal (FP for short) and SDL. While trying to…

HI,
I have a working copy imported from local disc ,now I want to update it from svn. How can I do it?

svn switch (--relocate) didn't help ,maybe I wrongly use them?

D:\work\svn\wc\fpc>svn switch http://svn.freepascal.org/svn/fpc/trunk d:/work/svn/wc/fpc svn: 'http://svn.freepascal.org/svn/fpc/trunk'
is not the same repository as
'file:///d:/work/svn/fpc'

D:\work\svn\wc\fpc>svn switch --relocate d:/work/svn/fpc http://svn.freepascal.org/svn/fpc/trunk svn: 'D:/work/svn/fpc' to 'http://svn.freepascal.org/svn/fpc/trunk' is not a val id relocation

What must be done in that case?

Florian Klaempfl
to Unknown author
HI, I have a working copy imported from local disc ,now I want to update it from svn. How can I do it?

How did you import? svn import doesn't work to get a working copy.

Show quoted text 17 lines
svn switch (--relocate) didn't help ,maybe I wrongly use them? D:\work\svn\wc\fpc>svn switch http://svn.freepascal.org/svn/fpc/trunk d:/work/svn/wc/fpc svn: 'http://svn.freepascal.org/svn/fpc/trunk' is not the same repository as 'file:///d:/work/svn/fpc' D:\work\svn\wc\fpc>svn switch --relocate d:/work/svn/fpc http://svn.freepascal.org/svn/fpc/trunk svn: 'D:/work/svn/fpc' to 'http://svn.freepascal.org/svn/fpc/trunk' is not a val id relocation What must be done in that case? _______________________________________________ fpc-other maillist - http://lists.freepascal.org/mailman/listinfo/fpc-other
Unknown author
to Florian Klaempfl
Show quoted text 6 lines
wrote: > HI, > I have a working copy imported from local disc ,now I want to update > it from svn. How can I do it? How did you import? svn import doesn't work to get a working copy.

svnadmin create d:/work/svn/fpc

svn import d:/work/tmp/fpc file:///d:/work/svn/fpc -m "Initial Import"

svn checkout file:///d:/work/svn/fpc/trunk file:///d:/work/svn/wc/fpc

After that I got working copy in d:/work/svn/wc/fpc. Now how can I change file://d:/work/svn/fpc/trunk to http://svn.freepascal.org/svn/fpc/trunk ?

Manually change all entries in ../.SVN/entries files? There are too many files to do that. Maybe there is predefined script in svn to do that?

Geno Roupsky
to Unknown author

2006/8/10, :

Show quoted text 18 lines
> wrote: >> HI, >> I have a working copy imported from local disc ,now I want to update >> it from svn. How can I do it? > How did you import? svn import doesn't work to get a working copy. svnadmin create d:/work/svn/fpc svn import d:/work/tmp/fpc file:///d:/work/svn/fpc -m "Initial Import" svn checkout file:///d:/work/svn/fpc/trunk file:///d:/work/svn/wc/fpc After that I got working copy in d:/work/svn/wc/fpc. Now how can I change file://d:/work/svn/fpc/trunk to http://svn.freepascal.org/svn/fpc/trunk ?

The problem is that each repository has unique GUID(or something like that) and the switch command doesn't allow switching between different repositories.

Manually change all entries in ../.SVN/entries files? There are too

many files to do that. Maybe there is predefined script in svn to do that?

You should better ask in the subversion mailing list ( http://subversion.tigris.org/servlets/ProjectMailingListList ) but I think you will have to use a script. Maybe somebody made one, I don't know, but you should ask the people there.

Florian Klaempfl
to Unknown author: svnadmin create d:/work/svn/fpc svn import d:/work/tmp/fpc file:///d:/work/svn/fpc -m…
Show quoted text 17 lines
> wrote: >> HI, >> I have a working copy imported from local disc ,now I want to update >> it from svn. How can I do it? > How did you import? svn import doesn't work to get a working copy. svnadmin create d:/work/svn/fpc svn import d:/work/tmp/fpc file:///d:/work/svn/fpc -m "Initial Import" svn checkout file:///d:/work/svn/fpc/trunk file:///d:/work/svn/wc/fpc After that I got working copy in d:/work/svn/wc/fpc. Now how can I change file://d:/work/svn/fpc/trunk to http://svn.freepascal.org/svn/fpc/trunk ?

This is not possible. You've to checkout from the fpc repository.