Sign in Join

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

Mailing lists / fpc-pascal / 2005-01

Runtime Error 216

10 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Bartek

hi,

after installing the new 1.9.6 release i tried to recompile and run my sdl programs. compilation runs fine ( but i had to restruct the majority of my for-loops, not beeing allowed to modify the counter variable ;\ ), but when i run my programs they all crashed beacuse of an access violation. this snippet is causing the crash. i'm not sure if it is my fault.

thanks in advance
bartek

program bug3;
type
  PSDL_Surface = ^TSDL_Surface;
  TSDL_Surface = record
    offset: Integer;
  end;
var
        screen          :psdl_surface;
function SDL_MustLock(Surface: pSDL_Surface): Boolean;
begin
  Result := ( surface^.offset  0 );
end;
begin
getmem(screen,sizeof(tsdl_surface));
sdl_mustlock(screen);
freemem(screen)
end.

¦ Free Pascal IDE Version 1.0.0 [2005/01/01]
¦ Compiler Version 1.9.6
¦ GBD Version GDB 6.2.1
¦ Cygwin "E:\fpc196\bin\i386-win32\cygwin1.dll" version 1005.12.0.0 Running "e:\fpc196\work\bug3.exe "
Runtime error 216 at $0040103F
$0040103F SDL_MUSTLOCK, line 13 of e:/fpc196/work/bug3.pas $0040106D main, line 19 of e:/fpc196/work/bug3.pas

Peter Vreman
to Bartek
you wrote 30 lines
hi, after installing the new 1.9.6 release i tried to recompile and run my sdl programs. compilation runs fine ( but i had to restruct the majority of my for-loops, not beeing allowed to modify the counter variable ;\ ), but when i run my programs they all crashed beacuse of an access violation. this snippet is causing the crash. i'm not sure if it is my fault. thanks in advance bartek program bug3; type PSDL_Surface = ^TSDL_Surface; TSDL_Surface = record offset: Integer; end; var screen :psdl_surface; function SDL_MustLock(Surface: pSDL_Surface): Boolean; begin Result := ( surface^.offset 0 ); end; begin getmem(screen,sizeof(tsdl_surface)); sdl_mustlock(screen); freemem(screen) end.

It runs fine here.

Try the commandline compiler without optimizer

Peter

Jonas Maebe
to Bartek: after installing the new 1.9.6 release i tried to recompile and run my sdl programs.…
Bartek wrote
after installing the new 1.9.6 release i tried to recompile and run my sdl programs. compilation runs fine ( but i had to restruct the majority of my for-loops, not beeing allowed to modify the counter variable ;\ ),

Delphi does not allow members of records to be used as 're probably going to do the same thing in the future, because checking whether or not a counter variable is modified in a loop is incompatible with the way record field symbols are stored (as you discovered before).

Show quoted text 26 lines
but when i run my programs they all crashed beacuse of an access violation. this snippet is causing the crash. i'm not sure if it is my fault. thanks in advance bartek program bug3; type PSDL_Surface = ^TSDL_Surface; TSDL_Surface = record offset: Integer; end; var screen :psdl_surface; function SDL_MustLock(Surface: pSDL_Surface): Boolean; begin Result := ( surface^.offset 0 ); end; begin getmem(screen,sizeof(tsdl_surface)); sdl_mustlock(screen); freemem(screen) end.

I can't reproduce this crash under Linux. Can you try with all optimizations turned off?

Jonas

Bartek
to Jonas Maebe

yes, you're right. after disabling the stack cheking it runs fine.

thanks

Earlier message 31 lines
----- Original Message ----- From: "Jonas Maebe" To: "FPC-Pascal users discussions" Sent: Monday, January 03, 2005 8:29 PM Subject: Re: [fpc-pascal] Runtime Error 216 > > On 3 jan 2005, at 20:19, Peter Vreman wrote: > >>> begin >>> getmem(screen,sizeof(tsdl_surface)); >>> sdl_mustlock(screen); >>> freemem(screen) >>> end. >> >> It runs fine here. >> >> Try the commandline compiler without optimizer > > It's not the optimizer, it's register variables in combination with > stack checking (-Ct -O-r) > > > Jonas > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
Bartek
to Jonas Maebe: It's not the optimizer, it's register variables in combination with stack checking (-Ct…

i've just recompiled all my programs with all optimization switches disabled and all checks disabled, just for curiosity, because you mentioned this problem. they are suddenly running perfectly fine. i think the code optimization or the checking is somehow broken...

Earlier message 31 lines
----- Original Message ----- From: "Jonas Maebe" To: "FPC-Pascal users discussions" Sent: Monday, January 03, 2005 8:29 PM Subject: Re: [fpc-pascal] Runtime Error 216 > > On 3 jan 2005, at 20:19, Peter Vreman wrote: > >>> begin >>> getmem(screen,sizeof(tsdl_surface)); >>> sdl_mustlock(screen); >>> freemem(screen) >>> end. >> >> It runs fine here. >> >> Try the commandline compiler without optimizer > > It's not the optimizer, it's register variables in combination with stack > checking (-Ct -O-r) > > > Jonas > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
Jonas Maebe
to Bartek
Bartek wrote
i've just recompiled all my programs with all optimization switches disabled and all checks disabled, just for curiosity, because you mentioned this problem. they are suddenly running perfectly fine. i think the code optimization or the checking is somehow broken...

Disabling the stack checking should be enough for now.

Jonas

Tomas Hajny
to Jonas Maebe

From: Jonas Maebe
Subject: Re: [fpc-pascal] Runtime Error 216 Date sent: Mon, 3 Jan 2005 22:03:18 +0100
To: FPC-Pascal users discussions
Send reply to: FPC-Pascal users discussions

Show quoted text 6 lines
> i've just recompiled all my programs with all optimization switches > disabled and all checks disabled, just for curiosity, because you > mentioned this problem. they are suddenly running perfectly fine. i > think the code optimization or the checking is somehow broken... Disabling the stack checking should be enough for now.

FWIW, I believe that it might be the same problem spotted by John in one of his snapshot compilation test runs quite some time ago... ;-)

Tomas

Vinzent Hoefler
to Jonas Maebe: Delphi does not allow members of records to be used as 're probably going to do the same…
Jonas Maebe wrote
Delphi does not allow members of records to be used as counters at all. We're probably going to do the same thing in the future,

You're already sort of done this. ;-)

(See my second message yesterday "operator overloading broken in 1.9.6?", so *this* question is answered in some way). Don't get me wrong: It's very good that you don't allow loop counters to be changed inside a for-loop now, but ...

because checking whether or not a counter variable is modified in a loop is incompatible with the way record field symbols are stored (as you discovered before).

... personally I don't like this part of the idea. There was a reason, I used those "loop"-records. Ok, I'll shut up for now and change the code.

Regards,

Vinzent.