[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Can anyone explain why this happened?
- To: "rtlinux" <rtl@rtlinux.org>
- Subject: Can anyone explain why this happened?
- From: "Norm Dresner" <ndrez@att.net>
- Date: Thu, 11 Oct 2001 21:15:06 -0400
Inside a function called by a real-time task, I coded a
"simple" routine to read the contents from a port. Because
I wanted not to even try to read from the address if the
corresponding board wasn't there, I put an if-statement in
front of the i/o read.
The code I wanted to write was:
...
if ( BoardOK[ boardno ] )
return inw( basePort );
else
return( -1 );
But instead I screwed up and wrote
...
if( BoardOK[ basePort ] ) // basePort ~ 0x300 while
boardno ~ 1-4
return inw( basePort );
else
return( -1 );
And the computer would *hang* every time the function was
called. I'm obviously addressing memory beyond the end of
the array and there's probably not enough static data in
the driver to allow addressing 0x300 * sizeof( int ) beyond
the end of it without running out of the address range
assigned to my driver's data segment either. [I know that
the hang in this routine and not after it returned data
because I had already commented out that code in an attempt
to isolate the problem.]
If I was addressing beyond the end of the virtual address
space for the kernel, I'd expect to get a segfault, not a
hang. And if there was memory there, why didn't I just
read a value instead of hanging so solidly that only the
reset or power switches would have any effect?
I don't know how rtlinux handles a sigfault so I'm hoping
that someone else does and can explain why this happened.
TIA
Norm