Xref: utzoo comp.lang.c:14305 comp.sys.m68k:1027 Path: utzoo!attcan!uunet!mcvax!enea!kth!draken!tut!santra!clinet!riku From: riku@clinet.FI (Riku Kalinen) Newsgroups: comp.lang.c,comp.sys.m68k Subject: Messing with 0 ptr on m68020 & sys V / 68 Summary: kinda weird Keywords: m68k null pointer Message-ID: <784@clinet.FI> Date: 25 Nov 88 14:18:21 GMT Reply-To: riku@clinet.fi (Riku Kalinen) Organization: City Lines Oy, Helsinki, Finland Lines: 52 First of all: I know, that messing around with 0 pointers is asking of trouble. The following is kinda intresting, however.. Hardware: Motorola 8400 business - unix box with m68020 Software: System V / 68 ver. 5.3.1 (?) [ Sys V rel 3 ] When i run the following program, it gives me 1024 '\0':s and then core dump (when offset gets into 1024). Seems that my process's address space contains 1 k read-only nulls in very beginnig. Questions: 1) Why? This causes reference thru 0 ptr to return 0 instead of core dump. (Of course, if I try to write something there, everything crashes as it should.) 2) Who sets up process's memory when it is started? Kernel? 3) Is there any good reasons to do this. /* --- clip --- clip --- clip --- */ /* baz.c - mess around with null pointer. */ #include #include main() { register char *base = 0; register unsigned long offset; register char ch; for (offset = (unsigned long) 0; offset < (unsigned long) 2000; offset ++) { cha = *(base + offset); /* dumps core when offset == 1024 == 1k */ printf ("%04lx = %d\n", offset, (int) cha); } } /* --- clip --- clip --- clip --- */ Please send responses via email, I'll summarize if I get something usable. And, PLEASE, PLEASE don't tell me this should never be done. I know it already, but sometimes it is fun to try something impossible 8-) . -- Riku "the bit" Kalinen Internet : riku@clinet.FI Elisa/s.mail : funet:riku@clinet.fi City Lines Inc, Helsinki, Finland Telephone int : +358 0 694 1056 -- "..We are what we are and it's never enough.." (Chris de Burgh) --