FPC causes internal error (2014081401 or 200208221) when using some expressions with method callbacks
Original Reporter info from Mantis: Michalis @michaliskambi
-
Reporter name: Michalis Kamburelis
Original Reporter info from Mantis: Michalis @michaliskambi
- Reporter name: Michalis Kamburelis
Description:
I attach two testcases, that cause two different Internal Errors from FPC, but they seem to be caused by the same problem:
- They use very similar syntax,
- have the same workaround,
- and both require -O2 to trigger.
$ fpc -Mobjfpc -Sh -O2 callback_expression_simple_testcase.pas
callback_expression_simple_testcase.pas(30,24) Fatal: Internal error 200208221callback_expression_simple_testcase.pas(30,24) Error: Compilation raised exception internally
Fatal: Compilation aborted
An unhandled exception occurred at $0000000000418A87:
EAccessViolation: Access violation
$0000000000418A87
The error occurs at line
Handled := MyItems[0](Received) or Handled;
The workaround is to simplify the expression using a temporary variable to hold the "MyItems0" result, like
EventResult := MyItems[0](Received);
Handled := EventResult or Handled;
The error does not occur with -O1, or without any optimizations. It also does not occur with any stable version of FPC (tested FPC 2.6.4, 3.0.0, 3.0.2).
The second testcase uses the same syntax, but with the Items property being defined by an ancestor class, which is a generic specialization. It causes a different Internal Error
$ fpc -Mobjfpc -Sh -O2 callback_expression_testcase_using_castlegenericlists.pas
callback_expression_testcase_using_castlegenericlists.pas(31,24) Fatal: Internal error 2014081401
Although the internal error is different, it points to the same line, and the workaround is similar. And it's also only with -O2.
Mantis conversion info:
- Mantis ID: 31421
- OS: Debian GNU/Linux
- OS Build: (testing)
- Build: 35460
- Platform: x86-64
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 35478 (#1adde896)