jwb@cepmax.ncsu.EDU (John W. Baugh Jr.) (09/11/90)
[Either this is a duplicate or my first one flew to never-never land.] I'm using gcc version 1.37.1 (with John Vasta's patches) to compile the following program on a DN4500 (SR10.2, BSD4.3): 1 main() 2 { 3 char x[10]; 4 long i; 5 6 for (i = 0; i <= 10; i++) x[i] = 'a'; 7 8 return 0; 9 } Upon executing the program I get: % a.out unable to unwind stack because of invalid stack frame (process manager/process fault manager) However, if I swap lines 3 and 4 it runs perfectly. Any ideas? Thanks, John Baugh jwb@cepmax.ncsu.edu
jwb@cepmax.ncsu.EDU (John W. Baugh Jr.) (09/11/90)
In article <1990Sep11.125319.21412@ncsuvx.ncsu.edu>, I suffer from complete brain damage: > 6 for (i = 0; i <= 10; i++) x[i] = 'a'; Thanks to jberets@bbn.com for gently correcting me. [Please, no flames--it's already been a rotten week, and I'm humiliated enough, all right? Sorry for the wasted bandwidth.] John Baugh jwb@cepmax.ncsu.edu
vasta@apollo.HP.COM (John Vasta) (09/12/90)
In article <1990Sep11.125319.21412@ncsuvx.ncsu.edu> jwb@cepmax.ncsu.edu writes: >I'm using gcc version 1.37.1 (with John Vasta's patches) to compile >the following program on a DN4500 (SR10.2, BSD4.3): > > 1 main() > 2 { > 3 char x[10]; > 4 long i; > 5 > 6 for (i = 0; i <= 10; i++) x[i] = 'a'; > 7 > 8 return 0; > 9 } > >Upon executing the program I get: > >% a.out >unable to unwind stack because of invalid stack frame (process >manager/process fault manager) > >However, if I swap lines 3 and 4 it runs perfectly. Any ideas? A classic pitfall - you're writing beyond the end of the array. Legal index values for a 10-element array range from 0 to 9, but you're writing to x[10]. John Vasta Hewlett-Packard Apollo Systems Division vasta@apollo.hp.com M.S. CHR-03-DW (508) 256-6600 x5978 300 Apollo Drive, Chelmsford, MA 01824 UUCP: {decwrl!decvax, mit-eddie, attunix}!apollo!vasta
sasdjb@unx.sas.com (David Biesack) (09/15/90)
In article <1990Sep11.125319.21412@ncsuvx.ncsu.edu> jwb@cepmax.ncsu.edu writes: > I'm using gcc version 1.37.1 (with John Vasta's patches) to compile > the following program on a DN4500 (SR10.2, BSD4.3): > 1 main() > 2 { > 3 char x[10]; > 4 long i; > 5 > 6 for (i = 0; i <= 10; i++) x[i] = 'a'; > 7 > 8 return 0; > 9 } > Upon executing the program I get: > % a.out > unable to unwind stack because of invalid stack frame (process > manager/process fault manager) I suspect the fact that you are storing too many characters into x is causing the crash. (The valid indices for x are 0 to 9, not 0 to 10 as your loop generates.) If you get the same crash with the loop coded as: for (i = 0; i < 10; i++) x[i] = 'a'; ^^^^^^ then I would worry.... I don't know all the ANSI C rules, but it would suprise me if it says you are allowed write beyond static arrays! > John Baugh > jwb@cepmax.ncsu.edu djb -- David J. Biesack SAS Institute, Inc. Object Programming Technology SAS Campus Drive sasdjb@dev.sas.com Cary, NC 27513-2414 rti!sas!sasdjb (919) 677-8000 ext. 7771