Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!philabs!prls!amdimage!amdcad!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: What is wrong with this program? Message-ID: <2680@sun.uucp> Date: Tue, 20-Aug-85 13:49:19 EDT Article-I.D.: sun.2680 Posted: Tue Aug 20 13:49:19 1985 Date-Received: Fri, 23-Aug-85 08:31:09 EDT References: <117@graffiti.UUCP> <7000003@convexs> Organization: Sun Microsystems, Inc. Lines: 25 > You have a pointer, but it doesn't point to anything. On > a Convex C-1, this leads to a core dump when "fread" tries to do a "bcopy" > with a null pointer.... which is invalid as a user address. On VAXen and > other machines, null pointers are valid user addresses, which can make > finding such problems a lot more difficult. On several other machines, null pointers are not valid user addresses; Suns and CCI Power 5/20s come to mind (not surprisingly). On VAXes running VMS, null pointers are not valid user addresses; on VAXes running System V Release 2 Version 2, or 4.2BSD with John Bruner's changes, there's a loader option to build executable images where null pointers aren't valid. Use these options - they can catch problems before you have to move your code to a machine where you have no alternative (besides, the chances are non-negligible that your code has a problem even if you can dereference a null pointer). > Hint: Learn about the program "lint" and use it regularly. It might have > saved you a lot of work. Amen. MANY program bugs (even ones in the kernel - I can testify to this) can be caught simply by using "lint". There may be some things that "you just can't get lint to shut up about", but better too many complaints than too few... Guy Harris