Mail Archives: djgpp/1996/08/18/17:31:25
I posted previously on the subject of segfaults in g++ programs linked
with libgrx under Linux. It took me quite a while to track the problem
down, but thanks to the advice of a number of kind people on these
newsgroups I have found what seems to be a number of errors in Linux
libgrx 1.0.4.
In order to do the job, I had to do the following.
* recompile the library with debugging information
* link the applications with ElectricFence
* run them under gdb on a second terminal attached
to my computer with standard error redirected to the
currently displayed virtual console, e.g.,
gdb testshape 2> /dev/tty1
The latter step was necessary because variables and pointers would
get corrupted when gdb forced the console back into text mode after a
segfault, rendering the backtrace information almost worthless.
Three off-by-one errors turned up in lnxmode.c. I suspect there may be
more, but someone who knows more about the code ought to have a look at
it to determine whether the errors I have identified really are errors,
and check that I have fixed them properly, and make sure that there are
no others. I'm all set up to debug the library now :) so if someone
wants to send me code to test, I would be more than happy.
Ed
--- lnxmode.c.orig Thu Aug 15 20:19:38 1996
+++ lnxmode.c Thu Aug 15 20:21:48 1996
@@ -199,7 +199,7 @@
return;
- for ( i = start; i <= end; i++)
+ for ( i = start; i < end; i++)
{
if (Dirty[i].flag == TRUE)
{
@@ -234,7 +234,7 @@
int i;
if (Accel == TRUE) return;
- for (i = 0; i <= _GrScreenY; i++)
+ for (i = 0; i < _GrScreenY; i++)
{
Dirty[i].flag =TRUE;
Dirty[i].starting = 0;
@@ -425,7 +425,7 @@
info = info_tmp;
}
}
- memset(&GM[modes+1], 0, sizeof(GR_DRIVER_MODE_ENTRY));
+ memset(&GM[modes], 0, sizeof(GR_DRIVER_MODE_ENTRY));
/* Third sort table */
for (i=modes-1; i>0; --i)
--
Ed Doolittle <dolittle AT math DOT toronto DOT edu>
"Being on time is like being on fire."
- Raw text -