Recent

Author Topic: Access violation  (Read 19098 times)

namrud

  • Guest
Access violation
« on: September 15, 2004, 07:28:45 pm »
Hello

After I got the newest source via CVS I tried to add a package (interbase).

1. menu->components->Open Package File (lpk)
2. A Fileopendialog appears

After selecting a file in the filedialog I got the message "Access violation" and the whole Lazarus IDE is terminated immediately.

Also now during compilation the message "Access violation" occurs.

Another question:

If I try this
.....
var r:real;
begin
   r := 16502.62
   r := r /10;
   ShowMessage(FloatToStr(r));
end;
....

The result is: 1650,26199999999

But this is wrong. Is this behaviour already known?

Kind regards

namrud

Anonymous

  • Guest
Access violation
« Reply #1 on: September 16, 2004, 12:38:02 am »
Same problem in a lot of other actions (like close all) or "Open".
Lazarus snapshot of 15 sep. h. 22:00 (GMT +1)

Kind regards
HJack

natter

  • Newbie
  • Posts: 1
same problem
« Reply #2 on: September 17, 2004, 03:19:10 pm »
i got the same error message every time i want to open or a save a file.
i hope somebody can help us.

Giuseppe Ridinò

  • Full Member
  • ***
  • Posts: 130
Re: Access violation (numerical calculation)
« Reply #3 on: September 17, 2004, 04:39:05 pm »
Quote from: "namrud"
If I try this
.....
var r:real;
begin
   r := 16502.62
   r := r /10;
   ShowMessage(FloatToStr(r));
end;
....

The result is: 1650,26199999999

But this is wrong. Is this behaviour already known?

It looks like a classical numerical calculation error due to the finite precision of numerical calculation.  :o
You can consider the result to be exact  :wink:
The problem may be located in the "/" algorithm or in the FloatToStr function. One should check it deeper.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Access violation
« Reply #4 on: September 18, 2004, 07:24:47 pm »
This is no error, but one of the basics of floating point calculation

For ordinal numbers is is clear, one can represent every decimal number in a binary number.  
for example, 1001 (base 2) is 9 (base 10), since 2^0 + 2^3 = 1 + 8 = 9.

now floating point:
1001.1001 (base 2) is 9.5625 (base 10) since 9 + 1/2 + 1/16 = 9.5625

Now back to your number. To write the 16502.62 (base 10) as a base 2 number, it has to be a combination of powers of 2 and powers of 1/2, so  that would be:
100000001110110.10011110101110000101000111101011100001......(etc)

You see that after I calculated 53 bits, it is still not excactly 16502.62,  there is still a fraction missing.
Since a real is 48 bit the last 1 wouldn't even be in there. So the value is at least 2^-38 (=3.6 E-12) missing. Therefore, the result is printed as 16502.619999999

(it is even worse, since those 48bits are for the number it self and the exponent)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Giuseppe Ridinò

  • Full Member
  • ***
  • Posts: 130
Access violation
« Reply #5 on: September 18, 2004, 07:57:14 pm »
Quote from: "Marc"
Since a real is 48 bit ......

 :shock: It should be 32 or 64 bits since a Real type is mapped with a Single or a Double type.
Reference: http://www.freepascal.org/docs-html/prog/progsu114.html#x160-1590008.2

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Access violation
« Reply #6 on: September 18, 2004, 08:00:35 pm »
OK, I was talking about the good old real as it existed in TP
reals shouldn't be used anymore (at least in delphi they are depreciated)
but being 64 bit doesn't change my story :) (the mantissa is 52 bits)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
Access violation
« Reply #7 on: September 19, 2004, 12:13:17 am »
Hello

Thanks for your reply.

At first I have to say that I still, got the Exception "Access violation", while using lazarus.

2 the other problem, I make some new tests:

1. Using a double var instead of real gives the same result
2. don't use a var:
   .....
   begin
      ShowMessage(FloatToStr(16502.62/10));
   end;
   ....
   The result is: 1650,262 !!!!
 
So I don't understand, why this works. In bose cases the compiler has to calculate the values. Am I wrong?

10x

namrud

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Access violation
« Reply #8 on: September 19, 2004, 12:31:01 am »
The calculations are not the same

16502.62/10 is calculated at compiletime while  
r := 16502.62;
r := r /10;
is calculated at runtime.

I don't know if 16502.62/10 is evaluated as double. These are compiler internals (and I don't know much of them)

BTW, about your AVs you still get them with latest CVS ? (lots of things are changed the last days) Otherwise report them on the ML.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
Access violation
« Reply #9 on: September 21, 2004, 07:47:01 pm »
The last time I looked at Lazarus was about a year ago.  Wow, really amazing progress.  Way to go guys!

Also Access Violation here too

Anonymous

  • Guest
Access violation
« Reply #10 on: September 21, 2004, 11:11:59 pm »
With the latest CVS I haven't longer this problem :-)

10x to all

namrud

Anonymous

  • Guest
Access violation
« Reply #11 on: September 29, 2004, 12:05:13 am »
namrud is right!
the newest CVS works fine!
No "Access Violations" anymore


after installation of  lazarus-0.9.2.1b-20040915-win32_binary.exe do that:

1. Download the newest sources (lazarus.zip)
ftp://ftp.freepascal.org/pub/fpc/snapshot/lazarus/lazarus.zip
and unzip this file to the upfolder of your lazarus installation.

(if Lazarus installed in "C:\lazarus"  ---> unzip to "C:")
(if Lazarus installed in "D:\Programme\lazarus"  ---> unzip to "D:\Programme")

2. to build the newest IDE you have to RENAME your lazarus.exe (to lazarusold.exe or something),
but make.exe cant build lazarus.exe if lazarus.exe is active)

3. Start your  "old" IDE (lazarusold.exe)

4. Enter the Path to the make.exe @ SETTINGS --> Environment Settings --> "Make Path"
for instance:
C:\Lazarus\pp\bin\win32\make.exe
or
D:\Programme\Lazarus\pp\bin\win32\make.exe
 
5. Start Build @ TOOLS ---> Compile Lazarus

6. Close IDE and open the "New" Lazarus.exe



Im new in Lazarus, but this works for me

Greetz
FearFactor

PabloIsensee

  • Newbie
  • Posts: 1
Access violation
« Reply #12 on: October 03, 2004, 10:50:20 pm »
Thanks,  FearFactor
your suggestions worked for me

PabloIsensee

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Access violation
« Reply #13 on: October 04, 2004, 07:00:20 pm »

kalwados

  • Newbie
  • Posts: 4
Access violation
« Reply #14 on: October 05, 2004, 09:43:09 pm »
Quote from: "Vincent"
A new win32 installer has been released today: http://sourceforge.net/project/showfiles.php?group_id=89339&package_id=105599


Cool. Why is the setup file so much smaller than previous versions? (24MB vs. 42MB)

Achim

 

TinyPortal © 2005-2018