The following program (with an error in it) crashes the compiler. The error (BSET undeclared) is detected, but then the compiler crashes trying to bail out.
I'm using gpc-20050331/gcc-3.4.3 with the delphi object patch.
Program, execution, and crash report follows. Peter.
program peterM;
type MyCollection = object function GetDataHandle: Integer; end;
function MyCollection.GetDataHandle: Integer; var flags: longint; begin flags := 0; BSET(flags, 16); GetDataHandle := flags; end;
begin WriteLn( 'OK' ); end.
gpc -o peterM peterM.pas peterM.pas: In method `MyCollection.GetDataHandle': peterM.pas:14: error: undeclared identifier `BSET' (first use in this routine) peterM.pas:14: error: (Each undeclared identifier is reported only once peterM.pas:14: error: for each routine it appears in.) peterM.pas:15: confused by earlier errors, bailing out [crash]
Date/Time: 2005-06-27 12:32:35.975 +0800 OS Version: 10.4.1 (Build 8B15) Report Version: 3
Command: gpc1 Path: /Developer/Pascal/gpc-20050331/libexec/gcc/powerpc-apple-darwin8.1.0/3.4.3/gpc1 Parent: gpc [2697]
Version: ??? (???)
PID: 2699 Thread: 0
Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000034
Thread 0 Crashed: 0 gpc1 0x0005324c expand_pascal_assignment + 288 (statements.c:1116) 1 gpc1 0x00009048 yyuserAction + 22488 (parse.c:4561) 2 gpc1 0x00010f9c main_yyparse + 544 (parse.c:7900) 3 gpc1 0x000c17c4 toplev_main + 1976 (toplev.c:1826) 4 gpc1 0x00002438 _start + 344 (crt.c:272) 5 gpc1 0x000022dc start + 60
Thread 0 crashed with PPC Thread State: srr0: 0x0005324c srr1: 0x0200f930 vrsave: 0x00000000 cr: 0x44004242 xer: 0x00000000 lr: 0x00053138 ctr: 0x00008ff4 r0: 0x00000028 r1: 0xbfffed00 r2: 0x00000000 r3: 0x40d29078 r4: 0x40d21e00 r5: 0xfefefeff r6: 0x80808080 r7: 0x00000000 r8: 0x00000000 r9: 0x40d26000 r10: 0x40d25b80 r11: 0x40d25b80 r12: 0x00008080 r13: 0x0033ad0c r14: 0x003455d8 r15: 0x00000001 r16: 0x0044bca8 r17: 0x0033a2fc r18: 0x00300d84 r19: 0x00000190 r20: 0x00300d84 r21: 0x00345be4 r22: 0x404cc4bc r23: 0x00000029 r24: 0xa0001bc8 r25: 0x00340d84 r26: 0x00000000 r27: 0x00000000 r28: 0x40d21e00 r29: 0x40d26f80 r30: 0x40d29078 r31: 0x00053138
Binary Images Description: 0x1000 - 0x443fff gpc1 /Developer/Pascal/gpc-20050331/libexec/gcc/powerpc-apple-darwin8.1.0/3.4.3/gpc1 0x40b54000 - 0x40b5bfff libintl.3.dylib /usr/local/lib/libintl.3.dylib 0x8fe00000 - 0x8fe50fff dyld 43 /usr/lib/dyld 0x90000000 - 0x901a6fff libSystem.B.dylib /usr/lib/libSystem.B.dylib 0x901fe000 - 0x90202fff libmathCommon.A.dylib /usr/lib/system/libmathCommon.A.dylib 0x90727000 - 0x90800fff com.apple.CoreFoundation 6.4.1 (368.1) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x9084b000 - 0x9094dfff libicucore.A.dylib /usr/lib/libicucore.A.dylib 0x909a7000 - 0x90a2bfff libobjc.A.dylib /usr/lib/libobjc.A.dylib 0x90ae3000 - 0x90af5fff libauto.dylib /usr/lib/libauto.dylib 0x91d33000 - 0x91d53fff libmx.A.dylib /usr/lib/libmx.A.dylib 0x92c9b000 - 0x92d89fff libiconv.2.dylib /usr/lib/libiconv.2.dylib 0x93614000 - 0x9361cfff libgcc_s.1.dylib /usr/lib/libgcc_s.1.dylib
Model: PowerMac7,3, BootROM 5.1.8f7, 2 processors, PowerPC G5 (3.0), 2 GHz, 1.5 GB Graphics: GeForce FX 5200, GeForce FX 5200, AGP, 64 MB Memory Module: DIMM0/J11, 256 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM1/J12, 256 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM2/J13, 512 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM3/J14, 512 MB, DDR SDRAM, PC3200U-30330 Modem: Jump, , V.92, Version 1.0, Network Service: Built-in Ethernet, Ethernet, en0 Serial ATA Device: ST3160023AS, 149.05 GB Parallel ATA Device: HL-DT-ST DVD-RW GWA-4082B, USB Device: CanoScan, Canon, Up to 12 Mb/sec, 500 mA USB Device: Hub, , Up to 12 Mb/sec, 500 mA USB Device: CF076, CF076, Up to 12 Mb/sec, 500 mA USB Device: Hub in Apple Pro Keyboard, Chicony, Up to 12 Mb/sec, 500 mA USB Device: Apple Optical USB Mouse, Logitech, Up to 1.5 Mb/sec, 100 mA USB Device: Apple Pro Keyboard, Chicony, Up to 12 Mb/sec, 250 mA USB Device: Studio Display, , Up to 1.5 Mb/sec, 500 mA
At 12:35 +0800 27/6/05, Peter N Lewis wrote:
The following program (with an error in it) crashes the compiler. The error (BSET undeclared) is detected, but then the compiler crashes trying to bail out.
Looks like there is either two bugs, or the above is related to the internal compiler error generated from the program below for assigning an object method return value. Peter.
gpc -o peterP peterP.pas peterP.pas: In method `MyCollection.GetDataHandle': peterP.pas:10: internal compiler error: Bus error Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
program peterP;
type MyCollection = object function GetDataHandle: Integer; end;
function MyCollection.GetDataHandle: Integer; begin GetDataHandle := 0; end;
begin WriteLn( 'OK' ); end.
Date/Time: 2005-06-27 13:03:45.584 +0800 OS Version: 10.4.1 (Build 8B15) Report Version: 3
Command: gpc1 Path: /Developer/Pascal/gpc-20050331/libexec/gcc/powerpc-apple-darwin8.1.0/3.4.3/gpc1 Parent: gpc [2803]
Version: ??? (???)
PID: 2805 Thread: 0
Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000034
Thread 0 Crashed: 0 gpc1 0x0005324c expand_pascal_assignment + 288 (statements.c:1116) 1 gpc1 0x00009048 yyuserAction + 22488 (parse.c:4561) 2 gpc1 0x00010f9c main_yyparse + 544 (parse.c:7900) 3 gpc1 0x000c17c4 toplev_main + 1976 (toplev.c:1826) 4 gpc1 0x00002438 _start + 344 (crt.c:272) 5 gpc1 0x000022dc start + 60
Thread 0 crashed with PPC Thread State: srr0: 0x0005324c srr1: 0x0200f930 vrsave: 0x00000000 cr: 0x48004242 xer: 0x00000000 lr: 0x00053138 ctr: 0x00008ff4 r0: 0x00000028 r1: 0xbfffed00 r2: 0x00000000 r3: 0x40d29078 r4: 0x40d21e00 r5: 0xfefefeff r6: 0x80808080 r7: 0x00000000 r8: 0x00000000 r9: 0x40d26000 r10: 0x40d25b80 r11: 0x40d25b80 r12: 0x00008080 r13: 0x0033ad0c r14: 0x003455d8 r15: 0x00000001 r16: 0x0044bca8 r17: 0x0033a2fc r18: 0x00300d84 r19: 0x00000190 r20: 0x00300d84 r21: 0x00345be4 r22: 0x404cc4bc r23: 0x00000019 r24: 0xa0001bc8 r25: 0x00340d84 r26: 0x00000000 r27: 0x00000000 r28: 0x40d21e00 r29: 0x40d27220 r30: 0x40d29078 r31: 0x00053138
Binary Images Description: 0x1000 - 0x443fff gpc1 /Developer/Pascal/gpc-20050331/libexec/gcc/powerpc-apple-darwin8.1.0/3.4.3/gpc1 0x40b54000 - 0x40b5bfff libintl.3.dylib /usr/local/lib/libintl.3.dylib 0x8fe00000 - 0x8fe50fff dyld 43 /usr/lib/dyld 0x90000000 - 0x901a6fff libSystem.B.dylib /usr/lib/libSystem.B.dylib 0x901fe000 - 0x90202fff libmathCommon.A.dylib /usr/lib/system/libmathCommon.A.dylib 0x90727000 - 0x90800fff com.apple.CoreFoundation 6.4.1 (368.1) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x9084b000 - 0x9094dfff libicucore.A.dylib /usr/lib/libicucore.A.dylib 0x909a7000 - 0x90a2bfff libobjc.A.dylib /usr/lib/libobjc.A.dylib 0x90ae3000 - 0x90af5fff libauto.dylib /usr/lib/libauto.dylib 0x91d33000 - 0x91d53fff libmx.A.dylib /usr/lib/libmx.A.dylib 0x92c9b000 - 0x92d89fff libiconv.2.dylib /usr/lib/libiconv.2.dylib 0x93614000 - 0x9361cfff libgcc_s.1.dylib /usr/lib/libgcc_s.1.dylib
Model: PowerMac7,3, BootROM 5.1.8f7, 2 processors, PowerPC G5 (3.0), 2 GHz, 1.5 GB Graphics: GeForce FX 5200, GeForce FX 5200, AGP, 64 MB Memory Module: DIMM0/J11, 256 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM1/J12, 256 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM2/J13, 512 MB, DDR SDRAM, PC3200U-30330 Memory Module: DIMM3/J14, 512 MB, DDR SDRAM, PC3200U-30330 Modem: Jump, , V.92, Version 1.0, Network Service: Built-in Ethernet, Ethernet, en0 Serial ATA Device: ST3160023AS, 149.05 GB Parallel ATA Device: HL-DT-ST DVD-RW GWA-4082B, USB Device: CanoScan, Canon, Up to 12 Mb/sec, 500 mA USB Device: Hub, , Up to 12 Mb/sec, 500 mA USB Device: CF076, CF076, Up to 12 Mb/sec, 500 mA USB Device: Hub in Apple Pro Keyboard, Chicony, Up to 12 Mb/sec, 500 mA USB Device: Apple Optical USB Mouse, Logitech, Up to 1.5 Mb/sec, 100 mA USB Device: Apple Pro Keyboard, Chicony, Up to 12 Mb/sec, 250 mA USB Device: Studio Display, , Up to 1.5 Mb/sec, 500 mA
Peter N Lewis wrote:
At 12:35 +0800 27/6/05, Peter N Lewis wrote:
The following program (with an error in it) crashes the compiler. The error (BSET undeclared) is detected, but then the compiler crashes trying to bail out.
Looks like there is either two bugs, or the above is related to the internal compiler error generated from the program below for assigning an object method return value. Peter.
The following patch fixed both crashes for me:
diff -u p.nn/statements.c p/statements.c --- p.nn/statements.c 2005-03-31 01:57:24.000000000 +0200 +++ p/statements.c 2005-06-27 23:19:47.906825912 +0200 @@ -1113,8 +1113,12 @@ if (CALL_METHOD (target)) { tree method_name = DECL_NAME (TREE_OPERAND (target, 1)); + tree op0 = TREE_OPERAND (target, 0); + tree t = TREE_TYPE (op0); + if (TYPE_POINTER_TO (t) && PASCAL_TYPE_CLASS (TYPE_POINTER_TO (t))) + t = TYPE_POINTER_TO (t); target = lookup_name (get_method_name ( - DECL_NAME (TYPE_NAME (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (target, 0))))), method_name)); + DECL_NAME (TYPE_NAME (TYPE_MAIN_VARIANT (t))), method_name)); if (!target) { error ("result of method `%s' assigned outside its block", IDENTIFIER_NAME (method_name));