Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following text was copied and pasted directly from a shell window after the original unmodified Scrollbox crashed: Program received signal SIGSEGV, Segmentation fault. 0x0000000000401a27

The following text was copied and pasted directly from a shell window after the original unmodified Scrollbox crashed:

Program received signal SIGSEGV, Segmentation fault.

0x0000000000401a27 in show (text=0x4065e0 "") at view.c:39

39 (*glyph[index])[line];

(gdb) list 33

28. // Characters start at " ", which is ASCII 0x20

29. // but is in the array at location 0.

30 c = (int) text[position];

31 index = c - 0x20;

32 if (debug) {

33 fprintf(stderr, "-%c", c);

34 fflush(stderr);

35 }

36

37 for (line=0; line < 10; line++) {

(gdb) list 37

32 if (debug) { 33 fprintf(stderr, "-%c", c); 34 fflush(stderr); 35 }

36

37 for (line=0; line < 10; line++) { 38 where[position + line * 9] = 39 (*glyph[index])[line]; 40 }

41

(gdb) info locals position = 0 line = 0 where = 0x406640 "" c=0

index = -32 (gdb)

(a) Which variables value caused this crash?

(b) Why did that variable have the value it did?

(c) Assume that the model cannot be modified for now, and the goal is to change this code so that the problem doesnt recur. Write an if statement that would prevent crashes, and indicate how it would be added to the code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions