Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1,284
    • Issues 1,284
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 55
    • Merge requests 55
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPCFPC
  • FPC SourceFPC Source
  • Issues
  • #37926
Closed
Open
Created Oct 14, 2020 by FPC Admin account@fpc_adminOwner

floating point exception leads to access violation

Original Reporter info from Mantis: BeniBela @benibela
  • Reporter name: Benito van der Zander

Description:

After several floating point exceptions, I get an access violation

Steps to reproduce:

This works without error:

var s, sr: single;
  i, j, tempcode: Integer;
begin
  Val('8.077936E-28', sr, tempcode);

  for i := 1 to 5000 do begin
    s := 0;
    try
      for  j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
    except
      on e: EMathError do s := 0; //continue;
    end;
  end;

  Val('8.077936E-28', sr, tempcode);
end.

This prints EOverflow: Floating point overflow

var s, sr: single;
  i, j, tempcode: Integer;
begin
  for i := 1 to 5000 do begin
    s := 0;
    try
      for  j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
    except
      on e: EMathError do s := 0; //continue;
    end;
    Val('8.077936E-28', sr, tempcode);
  end;
end.                          

This prints EAccessViolation: Access violation

procedure test(const s: single);
var
  tempcode: integer;
  sr: single;
begin
  Val('8.077936E-28', sr, tempcode);
  if sr <> s then
end;

var s, sr: single;
  i, j, tempcode: Integer;
begin
  for i := 1 to 5000 do begin
    s := 0;
    try
      for  j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
    except
      on e: EMathError do s := 0; //continue;
    end;
    test(s)
  end;
end.                             

Additional information:

Perhaps it is related to #37468 (closed) ?

Mantis conversion info:

  • Mantis ID: 37926
  • OS: linux
  • OS Build: opensuse
  • Build: r47006
  • Platform: amd64
  • Version: 3.3.1
  • Target version: 3.2.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking