Message-ID: <38276FE9.359D1B6@lycosmail.com> Date: Mon, 08 Nov 1999 19:50:49 -0500 From: Adam Schrotenboer X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Memory access error? References: <3fBV3.3521$1J5 DOT 335883 AT typhoon DOT mbnet DOT mb DOT ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Please try running a symify on this stack trace. Compile w/ "-gstabs" When the program crashes, type symify, which will then tell us what the eip values mean. W/o this, we cannot know what the problem is. Plus, when you are given the stack trace, you may find out what the problem is. Each compile is different, therefore it is near to impossible to know what any specific stack trace means. Philip Bock wrote: > I have posted several questions about a program I am working on to this > group over the last few weeks, and I just wanted to thank you all for the > great help you've been! I finally got my program to compile without any > errors, which is a bit of a feat considering it's the first time I've tried > all this object-oriented stuff. > > However, when I run it, it crashes with this error: > > Shutting down Allegro > Exiting due to signal SIGSEGV > General Protection Fault at eip=000018e0 > eax=65726168 ebx=00008394 ecx=00000000 edx=00000000 esi=00000054 > edi=0005c6e8 > ebp=000dc688 esp=000dc670 program=C:\DEVELOP\VECTOR2D\VECTOR.EXE > cs: sel=00a7 base=83949000 limit=000fffff > ds: sel=00af base=83949000 limit=000fffff > es: sel=00af base=83949000 limit=000fffff > fs: sel=00c7 base=00000000 limit=0010ffff > gs: sel=00c7 base=00000000 limit=0010ffff > ss: sel=00af base=83949000 limit=000fffff > App stack: [000dc6e8..0005c6e8] Exceptn stack: [0005c5c8..0005a688] > > Call frame traceback EIPs: > 0x000018e0 > 0x000015da > 0x000355ae > > Am I correct in assuming this has something to do with my constructors, or > what? (Note: the program doesn't include proper destructors, meaning that > some allocated memory is not explicitly deallocated. I was saving that for > version 2.0 : ) ) > > Code: > > #include > #include > #include > #include > > struct coord > { > int x, y; > }; > > struct vector > { > coord c1, c2; > int color; > }; > > struct shape > { > int numvects; > int stype; > int sfill; > vector **vects; > shape(int newnumvects, int newstype, int newsfill); > }; > > struct vimg > { > int numvectors, numshapes; > vector *vectors; > shape **shapes; > vimg(int nnumv, int nnums, int vpers[]); > }; > > void program_init(char program_title[]); > void draw_vimg(vimg *vectimg, int x, int y, int xscale, int yscale); > vimg *gen_vimg(void); > > int main(void) > { > program_init("Vector Graphics Rendering Demo"); > getch(); > set_gfx_mode(GFX_VESA1, 640, 480, 0, 0); > > vimg *mygraphic; > mygraphic = gen_vimg(); > draw_vimg(mygraphic, 200, 100, 1, 1); > > getch(); > > set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); > } > > void program_init(char program_title[]) > { > clrscr(); > > textcolor(BLACK); > textbackground(LIGHTGRAY); > for(int c = 1; c != 81; c++) > { > gotoxy(c, 1); > cprintf(" "); > } > for(int x = 0; program_title[x] != '\0'; x++) > gotoxy(40 - (x / 2), 1); > cout << program_title << '\n'; > textcolor(LIGHTGRAY); > textbackground(BLACK); > > cout << "Initializing Allegro library...\n"; > allegro_init(); > > cout << "Setting up timer...\n"; > install_timer(); > > cout << "Initializing mouse routines..."; > if (install_mouse() == -1) > cout << "failed\n"; > else > cout << '\n'; > cout << "Detected Operating System: "; > > if (os_type == OSTYPE_UNKNOWN) > cout << "MS-DOS\n"; > if (os_type == OSTYPE_WIN95) > cout << "Windows 95\n"; > if (os_type == OSTYPE_DOSEMU) > cout << "Linux DOSEMU\n"; > } > > void draw_vimg(vimg *vectimg, int x, int y, int xscale, int yscale) > { > for(int a = 0; a != vectimg->numshapes; a++) > { > file://Code to draw one shape's outline > for(int b = 0; b != vectimg->shapes[a]->numvects; b++) > line(screen, (vectimg->shapes[a]->vects[b]->c1.x*xscale)+x, > (vectimg->shapes[a]->vects[b]->c1.y*yscale)+y, > (vectimg->shapes[a]->vects[b]->c2.x*xscale)+x, > (vectimg->shapes[a]->vects[b]->c2.y*yscale)+y, > vectimg->shapes[a]->vects[b]->color); > file://Code to fill shape goes here. > } > } > > vimg *gen_vimg(void) > { > int vpers[]={6}; > vimg newvimg(6, 1, vpers); > > newvimg.vectors[0].c1.x = 50; > newvimg.vectors[0].c1.y = 1; > newvimg.vectors[0].c2.x = 100; > newvimg.vectors[0].c2.y = 1; > newvimg.vectors[0].color = 1; > newvimg.vectors[1].c1.x = 100; > newvimg.vectors[1].c1.y = 1; > newvimg.vectors[1].c2.x = 150; > newvimg.vectors[1].c2.y = 50; > newvimg.vectors[1].color = 1; > newvimg.vectors[2].c1.x = 150; > newvimg.vectors[2].c1.y = 50; > newvimg.vectors[2].c2.x = 100; > newvimg.vectors[2].c2.y = 100; > newvimg.vectors[2].color = 1; > newvimg.vectors[3].c1.x = 100; > newvimg.vectors[3].c1.y = 100; > newvimg.vectors[3].c2.x = 50; > newvimg.vectors[3].c2.y = 100; > newvimg.vectors[3].color = 1; > newvimg.vectors[4].c1.x = 50; > newvimg.vectors[4].c1.y = 100; > newvimg.vectors[4].c2.x = 1; > newvimg.vectors[4].c2.y = 50; > newvimg.vectors[4].color = 1; > newvimg.vectors[5].c1.x = 1; > newvimg.vectors[5].c1.y = 50; > newvimg.vectors[5].c2.x = 50; > newvimg.vectors[5].c2.y = 1; > newvimg.vectors[5].color = 1; > > newvimg.shapes[0]->vects[0] = &newvimg.vectors[0]; > newvimg.shapes[0]->vects[1] = &newvimg.vectors[1]; > newvimg.shapes[0]->vects[2] = &newvimg.vectors[2]; > newvimg.shapes[0]->vects[3] = &newvimg.vectors[3]; > newvimg.shapes[0]->vects[4] = &newvimg.vectors[4]; > newvimg.shapes[0]->vects[5] = &newvimg.vectors[5]; > } > > shape::shape(int newnumvects, int newstype, int newsfill) > { > numvects = newnumvects; > stype = newstype; > sfill = newsfill; > vects = new vector *[newnumvects]; > } > > vimg::vimg(int nnumv, int nnums, int vpers[]) > { > numvectors = nnumv; > numshapes = nnums; > vectors = new vector [nnumv]; > shapes = new shape *[nnums]; > for (int c = 0; c != nnums; c++) > shapes[c] = new shape(vpers[c], 0, 0); > }