Page 4 of 4

Re: Null pointers and pointer safety

Posted: Wed May 31, 2017 8:47 pm
by StudlyCaps
goku420: I was more thinking of a static analysis situation where you're trying to find out before starting a program if it will fault or not. In that case you'd have to have to do some type of state machine analysis to determine if the variable will be valid in all cases when the code actually runs.

Re: Null pointers and pointer safety

Posted: Wed May 31, 2017 9:09 pm
by goku420
StudlyCaps wrote:goku420: I was more thinking of a static analysis situation where you're trying to find out before starting a program if it will fault or not. In that case you'd have to have to do some type of state machine analysis to determine if the variable will be valid in all cases when the code actually runs.
This would only work for degenerate cases like null pointer dereferences, otherwise like you said it is essentially the halting problem. However, the behavior of your page fault handler ultimately doesn't matter since the danger in invalid pointers comes from type punning, violating strict aliasing, out of bounds, etc. The latter three cases are easily caught by static analyzers.

Re: Null pointers and pointer safety

Posted: Wed May 31, 2017 11:02 pm
by StudlyCaps
You misunderstand me I think. I'm deliberately giving an example of something that won't work (or that isn't practical)! Someone earlier in the thread proposed that all binaries could be statically analysed by the OS and that programs which have unsafe pointer use can just not be run, making the system more stable. I was giving a counter example to say, in this case, that isn't feasible.