Waldek Hebisch wrote:
Now the question is why do we get range check error and what is happening in `FileHandle' (maybe `StdErr' is uninitialized).
The first question remains.
Could you check the following program:
Program Pack2;
Var a: packed array [ 1..1 ] of Boolean; i: integer; begin i:= 1 ; a [ i ]:= true end.
I assume that it fails. But the machine code contains 10 comparisons, and it is not clear which one fails. The simplest method is probably to use `stepi' in gdb (or eqivalent metod to step trough machine instructions).
Backtrace for fjf659o.pas:
Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0x000e6014
Thread 0 Crashed: 0 a.out 0x0000eeb4 _p_Write_Init + 0x34 (files.pas:518) 1 a.out 0x0000231c _p__M0_main_program + 0xac (fjf659o.pas:10) 2 a.out 0x00002470 main + 0x34 (<implicit code>:12) 3 a.out 0x00001ea8 _start + 0x188 (crt.c:267) 4 dyld 0x8fe1a558 _dyld_start + 0x64
Looks like _p_Write_Init is accessing freed file. We either need `Finalize' to set its argument to an invalid file (FDR) or to nil. In the second case all IO routines would have to check for nil.