Page 1 of 1
Segment Write Exception
Posted: Thu Sep 29, 2011 7:02 pm
by janktrank
I thought this was a somewhat interesting phenomenon but found myself unable to explain it. When reading from a memory location that is explicitly qualified to utilize the CS segment register, and storing that value, the logical address (offset component) essentially serves as the linear address (i.e. a flat-memory model) and the contents of the memory address provided are written to the storage location operand. Code selectors can be read from, so this is normal. Upon writing to a location that is explicitly qualified to use the CS segment register, a fault is generated; this is also normal as code selectors cannot be written to. However, the fault claims that an illegal memory read from 0xffffffff has been made. Where did this come from? Is the process actually attempting to read from this address or does the act of writing to a read-only segment simply output that an invalid read was attempted at the segment's limit?
Thanks for the insight.
Re: Segment Write Exception
Posted: Fri Sep 30, 2011 3:50 am
by Combuster
I don't know how you observed that.
A segment violation yields a GPF with the segment as the error code. It does not provide you directly with the segment offset responsible, you have to find that out yourself by disassembling the faulted instruction and computing the value of its memory operands.
Re: Segment Write Exception
Posted: Fri Sep 30, 2011 3:38 pm
by janktrank
Combuster wrote:I don't know how you observed that.
I was using inline assembly in VC 2010. I used the logical address
x of a local on the current call stack.
Quite simply
resulted in an invalid read at 0xffffffff fault when debugging.
Re: Segment Write Exception
Posted: Sat Oct 01, 2011 3:11 pm
by gerryg400
It sounds like you are running your software under windows. If this is the case then the message you get will be whatever windows and its debugger decide to give you.
To guarantee that you can see the 'real' fault information you need to write your own operating system and your own fault handlers. Then you will see what Combuster described.