Null pointers and pointer safety

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
StudlyCaps
Member
Member
Posts: 225
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: Null pointers and pointer safety

Post 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.
goku420
Member
Member
Posts: 51
Joined: Wed Jul 10, 2013 9:11 am

Re: Null pointers and pointer safety

Post 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.
StudlyCaps
Member
Member
Posts: 225
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: Null pointers and pointer safety

Post 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.
Post Reply