*BSD News Article 26169


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!nic.hookup.net!swrinde!cs.utexas.edu!not-for-mail
From: swanton@moose.usmcs.maine.edu (George P. Swanton)
Newsgroups: comp.os.386bsd.questions
Subject: [Q] *(int*)NULL Ok??
Date: 18 Jan 1994 08:21:55 -0600
Organization: UTexas Mail-to-News Gateway
Lines: 30
Sender: daemon@cs.utexas.edu
Message-ID: <9401181422.AA18524@moose.usmcs.maine.edu>
NNTP-Posting-Host: cs.utexas.edu

I was stepping through some code last night and was allowed to perform
the equivalent of 

gdb> p *(int*)0
(FreeBSD-1.0R, whatever the default gdb is0

The following program also runs without complaint on both this and my 
NetBSD-0.8 system (both nobrand 486dx)

main() { 
  int i;
  i = *(int*)0;
}

however, 

  *(int*)0 = 1;

causes a fault.

My assumption is that this is a 386 'feature', ie vaddr 0 is probably mapped
as code and execute implies read as far as Intel is concerned (just guessing,
it's been a while since I've read any 386 stuff)

If this is not the case, is there any way to disable this behavior?

Not complaining/flaming/trying to start a holy war, just curious.

gps