Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bu.edu!buitc!gjc From: gjc@buitc.bu.edu (George J. Carrette) Newsgroups: comp.arch Subject: CRASHME.C, test your hardware and software robustness Keywords: testing hardware software Message-ID: <71539@bu.edu.bu.edu> Date: 3 Jan 91 18:23:58 GMT Sender: news@bu.edu.bu.edu Reply-To: gjc@buitc.bu.edu (George J. Carrette) Followup-To: comp.arch Organization: Information Technology, Boston University, Boston, MA, USA Lines: 275 Here is the promised CRASHME.C. It has been reported that the behavior of this program is highly dependant on system load, amount of system memory, etc. The results are not easily to reproduce in many cases. If you really want to give a system the acid test then create a shell script with thousands of different calls to crashme, and run multiple copies of these at the same time in different processes. BEWARE: Obviously, DO NOT RUN THIS on a MACHINE WHICH HAS OTHER USERS, or is a FILESERVER. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh crashme.1 <<'END_OF_crashme.1' X.TH CRASHME 1C LOCAL X.SH NAME Xcrashme \- test operating environment software robustness X.SH SYNOPSIS X.B crashme X[NBYTES] [SRAND] [NRYTES] X.SH DESCRIPTION X.I crashme Xis a very simple program that tests the operating environment's Xrobustness by invoking random data as if it were a procedure. XThe standard signals are caught and handled with a setjmp back Xto a loop which will try again to produce a fault by executing Xrandom data. X X.RE X.SS COMMAND LINE OPTIONS X.TP 8 X.BI [NBYTES] XThe X.I [NBYTES] Xshould be an integer, specifying the size of the random data string Xin bytes. X.TP X.BI [SRAND] XThe X.I [SRAND] Xis an input seed to the random number generator, passed to srand. X.TP X.BI [NTRIES] XThe X.I [NTRIES] Xis how many times to loop before exiting normally from the program. X.SH FILES Xcrashme.c X.PD X.SH DIAGNOSTICS XWhen a signal is caught the number and nature of the signal is indicated. X.SH BUGS XNot all signals are caught, and the state of the user program/process Xenviroment can be sufficiently damaged such that the program terminates Xbefore going through all [NTRIES] operations. X XBeware: This program can crash your computer and possibly corrupt Xyour files if the operating system on it is buggy. X.SH AUTHOR XGeorge J Carrette. GJC\@BU-IT.BU.EDU END_OF_crashme.1 if test 1250 -ne `wc -c crashme.c <<'END_OF_crashme.c' X/* crashme: Create a string of random bytes and then jump to it. X crashme */ X Xchar *crashme_version = "1.1 19-SEP-1990"; X X/* X * COPYRIGHT (c) 1990 BY * X * GEORGE J. CARRETTE, CONCORD, MASSACHUSETTS. * X * ALL RIGHTS RESERVED * X XPermission to use, copy, modify, distribute and sell this software Xand its documentation for any purpose and without fee is hereby Xgranted, provided that the above copyright notice appear in all copies Xand that both that copyright notice and this permission notice appear Xin supporting documentation, and that the name of the author Xnot be used in advertising or publicity pertaining to distribution Xof the software without specific, written prior permission. X XTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL XHE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS XSOFTWARE. X XA signal handler is set up so that in most cases the machine exception Xgenerated by the illegal instructions, bad operands, etc in the procedure Xmade up of random data are caught; and another round of randomness may Xbe tried. Eventually a random instruction may corrupt the program or Xthe machine state in such a way that the program must halt. This is Xa test of the robustness of the hardware/software for instruction Xfault handling. X X Note: XSeen to be able to crash a SUN-4/110 OS 4.1, SUN-4/280 OS 4.0.3: X %crashme 1000 10 200 XAlso various combinations of inputs have been reported to crash Xother machines. X XComments may be addressed to the author at GJC@BU-IT.BU.EDU X XVersion Date Description X---------------------------------------------------------------------- X 1.0 early 1990 initial hack. X 1.1 19-SEP-1990 added more signals and an alarm to abort looping. X X*/ X X X#include X#include X#include X Xlong nbytes,nseed,ntrys; Xunsigned char *the_data; X Xjmp_buf again_buff; X Xvoid (*badboy)(); X Xvoid again_handler(sig, code, scp, addr) X int sig, code; X struct sigcontext *scp; X char *addr; X{char *ss; X switch(sig) X {case SIGILL: ss = " illegal instruction"; break; X case SIGTRAP: ss = " trace trap"; break; X case SIGFPE: ss = " arithmetic exception"; break; X case SIGBUS: ss = " bus error"; break; X case SIGSEGV: ss = " segmentation violation"; break; X case SIGIOT: ss = " IOT instruction"; break; X case SIGEMT: ss = " EMT instruction"; break; X case SIGALRM: ss = " alarm clock"; break; X default: ss = "";} X fprintf(stderr,"Got signal %d%s\n",sig,ss); X longjmp(again_buff,3);} X Xset_up_signals() X{signal(SIGILL,again_handler); X signal(SIGTRAP,again_handler); X signal(SIGFPE,again_handler); X signal(SIGBUS,again_handler); X signal(SIGSEGV,again_handler); X signal(SIGIOT,again_handler); X signal(SIGEMT,again_handler); X signal(SIGALRM,again_handler);} X Xcompute_badboy() X{long j,n; X n = (nbytes < 0) ? - nbytes : nbytes; X for(j=0;j> 7) & 0xFF; X if (nbytes < 0) X {fprintf(stdout,"Dump of %ld bytes of data\n",n); X for(j=0;j 0) X (*badboy)(); X else if (nbytes == 0) X while(1);} X Xmain(argc,argv) X int argc; char **argv; X{if (argc != 4) {fprintf(stderr,"crashme \n"); X exit(1);} X fprintf(stdout,"Crashme: (c) Copyright 1990 George J. Carrette\n"); X fprintf(stdout,"Version: %s\n",crashme_version); X nbytes = atol(argv[1]); X nseed = atol(argv[2]); X ntrys = atol(argv[3]); X fprintf(stdout,"crashem %ld %ld %ld\n",nbytes,nseed,ntrys); X fflush(stdout); X the_data = (unsigned char *) malloc((nbytes < 0) ? -nbytes : nbytes); X badboy = (void (*)()) the_data; X fprintf(stdout,"Badboy at %d. 0x%X\n",badboy,badboy); X srand(nseed); X badboy_loop();} X Xbadboy_loop() X{int i; X for(i=0;imakefile <<'END_OF_makefile' Xcrashme: crashme.o X cc -o crashme crashme.o Xcrashme.o: crashme.c X cc -c crashme.c END_OF_makefile if test 82 -ne `wc -c readme <<'END_OF_readme' XThe purpose of the crashme program is to cause instruction faults Xthat would otherwise be only rarely seen in the normal operation Xof a system (where "normal" includes conditions of user programs Xwith bugs in them, and to executable code corruption due to Xmemory, disk, and network problems). X XCaution: Don't even *think* about running this program on a Xsystem without a projected mode operating of some kind. X XFor more information see the comments in the code. X XNote: The use of srand and rand is unlikely to result in a very Xgood random mapping unto a machine instruction set. X XInfinite loops will be broken out of (presumably) by the ALARM Xsignal. 10 seconds are given for this. Adjust as needed. X XIdeally a shell script should be set up to run crashme again and Xagain for hours and hours with different input settings. X X-George Carrette. GJC@BU-IT.BU.EDU END_OF_readme if test 859 -ne `wc -c