Skip to content

Converting a string to a float can trigger unrecoverabe SIGFPE

Original Reporter info from Mantis: Eric
  • Reporter name: Eric Grange

Description:

The following code attempts to convert a string representing a floating point value that can't be represented in a float, it triggers two SIGFPE that aren't recoverable (Windows kills the app).

The except block is not entered, executable crashes.

program Project1;

{$mode delphi}

uses
   SysUtils;

var
   v : Double;
begin
  try
    TryStrToFloat('9e9999', v);
  except
    on e: Exception do begin
      writeln(e.ClassName);
      readln;
    end;
  end;
end.

Mantis conversion info:

  • Mantis ID: 22809
  • OS: Windows
  • Version: 2.7.1
  • Monitored by: » Eric (Eric Grange)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information