I am having some wierd problems with bus errors and seg faults under MacOS X. I am using the currently available release (linked from the GPC binary downloads area), and am wondering when an update will be made available, hoping that some of these problems have been (or will be) fixed.
The strange thing is that sometimes the problem can be fixed by sticking extra WRITELNs in between various lines of code. So for example, if I am having trouble and think the following code is at fault:
x := SomeFunction(y, z); DoSomethingTo(x);
I might change it to:
WRITELN('1'); x := SomeFunction(y, z); WRITELN('2'); DoSomethingTo(x); WRITELN('3');
and sometimes this fixes the problem (but of course, I don't want that extra output...)
Any ideas/fixes/patches?
Thank you.
===== ======= Frank D. Engel, Jr.
Modify the equilibrium of the vertically-oriented particle decelerator to result in the reestablishment of its resistance to counterproductive atmospheric penetration.
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
----- Original Message ----- From: "Frank D. Engel, Jr." fde101@yahoo.com To: gpc@gnu.de Sent: Friday, August 08, 2003 3:17 PM Subject: MacOS X Update Request due to strange problem
I am having some wierd problems with bus errors and seg faults under MacOS X. I am using the currently available release (linked from the GPC binary downloads area), and am wondering when an update will be made available, hoping that some of these problems have been (or will be) fixed.
The strange thing is that sometimes the problem can be fixed by sticking extra WRITELNs in between various lines of code. So for example, if I am having trouble and think the following code is at fault:
<snip>
I have had similar problems with Borland Pascal. What I usually do is either put in extra blank lines or comments before the line where the problem occurs. The problem is not consistent and I have never been able to detect a pattern. The comments that I use are usually in the form of /*************************/
Frank D. Engel, Jr. wrote:
I am having some wierd problems with bus errors and seg faults under MacOS X. I am using the currently available release (linked from the GPC binary downloads area), and am wondering when an update will be made available, hoping that some of these problems have been (or will be) fixed.
It would be helpful if you give a more precise descriptions of the problems you encounter, provide compiler output, possibly source code, a crash reporting log of the Mac OS X Console application, etcetera. You can send it to the list or to my email address.
One thing that may help is to reboot Mac OS X.
Regards,
Adriaan van Os
Okay, here goes:
The program is a compiler for a modified version of Pascal, which I am designing as part of my Master's project. The program converts code from the modified Pascal dialect into Objective C code. One concept of my objective is to be able to write and compile Cocoa programs with a Pascal-type syntax. Consider the following procedure:
PROCEDURE MatchParamList(args1, args2 : POINTER); VAR i : INTEGER;
BEGIN WRITELN('1'); IF ((args1 = NIL) AND (args2 <> NIL)) OR ((args1 <> NIL) AND (args2 = NIL)) OR_ELSE ((args1 <> NIL) AND_THEN (GetFieldCount(args1) <> GetFieldCount(args2))) THEN BEGIN WRITELN('2a'); Error('Definition does not match forward declaration') END ELSE BEGIN WRITELN('2b'); FOR i := 1 TO GetFieldCount(args1) DO BEGIN WRITE('-'); IF (IsFieldVar(args1, i) <> IsFieldVar(args2, i)) OR (GetFieldName(args1, i) <> GetFieldName(args2, i)) OR (GetFieldType(args1, i) <> GetFieldType(args2, i)) THEN Error('Definition does not match forward declaration') END END ;WRITELN('3') END;
With the WRITELNs (flush-left) in place, the program compiles and runs correctly, producing the expected output, except for all the undesired WRITELN output.
Now comment out the WRITELNs:
PROCEDURE MatchParamList(args1, args2 : POINTER); VAR i : INTEGER;
BEGIN {WRITELN('1');} IF ((args1 = NIL) AND (args2 <> NIL)) OR ((args1 <> NIL) AND (args2 = NIL)) OR_ELSE ((args1 <> NIL) AND_THEN (GetFieldCount(args1) <> GetFieldCount(args2))) THEN BEGIN {WRITELN('2a');} Error('Definition does not match forward declaration') END ELSE BEGIN {WRITELN('2b');} FOR i := 1 TO GetFieldCount(args1) DO BEGIN {WRITE('-');} IF (IsFieldVar(args1, i) <> IsFieldVar(args2, i)) OR (GetFieldName(args1, i) <> GetFieldName(args2, i)) OR (GetFieldType(args1, i) <> GetFieldType(args2, i)) THEN Error('Definition does not match forward declaration') END END {;WRITELN('3')} END;
And the program now crashes with a bus error (opas is the program compiled with GPC, then opas is run on the file opas_sys.pas to produce opas_sys.m and opas_sys.h, which are handed to GCC to generate opas_sys.o):
bash-2.05a$ make gpc --automake -o opas opas.pas ./opas opas_sys make: *** [opas_sys.o] Bus error bash-2.05a$
The console reads as follows:
Aug 9 14:35:10 g3 crashdump: Crash report written to: /Users/fde101/Library/Logs/CrashReporter/opas.crash.log
And that file reads:
**********
Date/Time: 2003-08-09 14:35:10 -0400 OS Version: 10.2.6 (Build 6L60) Host: g3.local.
Command: opas PID: 833
Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
Thread 0 Crashed: #0 0x00034e60 in Isfieldvar (crt.c:300) #1 0x0000eae0 in Matchparamlist (crt.c:300) #2 0x00010e00 in Parseprocedure (crt.c:300) #3 0x00012d8c in Parseheader (crt.c:300) #4 0x00002668 in Parseunitimplementation (crt.c:300) #5 0x00004a30 in Parseunitcompile (crt.c:300) #6 0x0002eae0 in Tracecompilationunit (crt.c:300) #7 0x0003b654 in pascal_main_program (crt.c:300) #8 0x0003b7b4 in main (crt.c:300) #9 0x00001d9c in _start (crt.c:267) #10 0x00001c1c in start
PPC Thread State: srr0: 0x00034e60 srr1: 0x0000f030 vrsave: 0x00000000 xer: 0x00000000 lr: 0x0000eae0 ctr: 0x00000001 mq: 0x00000000 r0: 0x000000d8 r1: 0xbfff57b0 r2: 0x0408040c r3: 0x00000000 r4: 0x00000001 r5: 0x00000001 r6: 0x0000003b r7: 0x00008080 r8: 0x000026ad r9: 0x00000000 r10: 0x00000001 r11: 0x0019f000 r12: 0x90013d40 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000 r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000 r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000 r24: 0x00000000 r25: 0x00000000 r26: 0xbffffddc r27: 0x0000000c r28: 0x00000002 r29: 0xbfff9240 r30: 0xbfff57b0 r31: 0x0000e8dc
Hope that helps!
BTW, the problem is consistant across reboots.
--- Adriaan van Os gpc@microbizz.nl wrote:
Frank D. Engel, Jr. wrote:
I am having some wierd problems with bus errors and seg faults
under
MacOS X. I am using the currently available release (linked from
the
GPC binary downloads area), and am wondering when an update will be made available, hoping that some of these problems have been (or
will
be) fixed.
It would be helpful if you give a more precise descriptions of the problems you encounter, provide compiler output, possibly source code, a crash reporting log of the Mac OS X Console application, etcetera. You can send it to the list or to my email address.
One thing that may help is to reboot Mac OS X.
Regards,
Adriaan van Os
===== ======= Frank D. Engel, Jr.
Modify the equilibrium of the vertically-oriented particle decelerator to result in the reestablishment of its resistance to counterproductive atmospheric penetration.
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Frank D. Engel, Jr. wrote:
Okay, here goes:
The program is a compiler for a modified version of Pascal, which I am designing as part of my Master's project. The program converts code from the modified Pascal dialect into Objective C code. One concept of my objective is to be able to write and compile Cocoa programs with a Pascal-type syntax.
A very interesting project.
And the program now crashes with a bus error (opas is the program compiled with GPC, then opas is run on the file opas_sys.pas to produce opas_sys.m and opas_sys.h, which are handed to GCC to generate opas_sys.o):
Pardon me asking, but did you try to increase the stacksize ?
[G4:~/gnu/testgpc/adriaan] adriaan% limit stacksize 4096
Frank Heckenbach wrote:
Like Adriann said, without a reproducing case, we can't help you much.
Can you send me full source code (with a makefile or building instructions) ? Then, we can see if we can reproduce it on Mac OS X and possibly on other platforms.
It may be a GPC bug, it may also be a bug in your code (think of undefined values). Chances that it will be fixed by accident (if it's a GPC bug at all) are minimal.
Try the following, to check for uninitialized variables:
[G4:~/gnu/testgpc/adriaan] adriaan% gpc opas.pas -O1 -Wuninitialized
Regards,
Adriaan van Os
Pardon me asking, but did you try to increase the stacksize ?
[G4:~/gnu/testgpc/adriaan] adriaan% limit stacksize 4096
bash-2.05a$ tcsh [g3:~/opas] fde101% limit stacksize 4096 [g3:~/opas] fde101% make ./opas opas_sys make: *** [opas_sys.o] Bus error [g3:~/opas] fde101% limit stacksize 20000 [g3:~/opas] fde101% make ./opas opas_sys make: *** [opas_sys.o] Bus error [g3:~/opas] fde101%
Can you send me full source code (with a makefile or building instructions) ? Then, we can see if we can reproduce it on Mac OS X and possibly on other platforms.
I might do this soon, but need to check some things first.
However, I have a slightly older version of GPC (release 2.1, I think?) on my SGI O2 (IRIX 6.5.x, x=?? offhand, 15 or 17 I think), and tried it there:
bash-2.00$ make gpc --big-endian --automake -o opas opas.pas ./opas opas_sys *** Termination code 139 (bu21)
Try the following, to check for uninitialized variables:
[G4:~/gnu/testgpc/adriaan] adriaan% gpc opas.pas -O1 -Wuninitialized
There were several listed, but I checked the logic in the files and none of them are actually correct; the variables will always be initialized first.
I found this line to be rather interesting, though:
header.pas:160: warning: `result_71' might be used uninitialized in this function
:-)
===== ======= Frank D. Engel, Jr.
Modify the equilibrium of the vertically-oriented particle decelerator to result in the reestablishment of its resistance to counterproductive atmospheric penetration.
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Frank D. Engel, Jr. wrote:
The strange thing is that sometimes the problem can be fixed by sticking extra WRITELNs in between various lines of code. So for example, if I am having trouble and think the following code is at fault:
x := SomeFunction(y, z); DoSomethingTo(x);
I might change it to:
WRITELN('1'); x := SomeFunction(y, z); WRITELN('2'); DoSomethingTo(x); WRITELN('3');
and sometimes this fixes the problem (but of course, I don't want that extra output...)
Any ideas/fixes/patches?
Like Adriann said, without a reproducing case, we can't help you much. It may be a GPC bug, it may also be a bug in your code (think of undefined values). Chances that it will be fixed by accident (if it's a GPC bug at all) are minimal.
Frank