DiBR
обычная кошмарная
домашняя страничка
Ежекакполучится околокомпьютерное обозрение
 
  <<<  предыдущий Tech! archive #95 следующий  >>>  
   Последний выпуск       Архив       Ссылки       Полезности       humor.filtered       Фотки       О сайте   
          Это - достаточно беспорядочный архив сообщений конференций сети fidonet, которые на момент их прочтения мной показались полезными или интересными. Многие устарели, многие узкоспецифичны и малоинтересны, но может оказаться и что-то новое...
         
- __techs (2:5015/42) ----------------------------------------------- __techs -
Msg  : 95 of 1000                          Pvt
From : Nick Vasilyev                       2:5030/25.70    26 Sep 96  09:59:30
To   : All                                                 28 Sep 96  22:43:46
Subj : crashme (2/3)
-------------------------------------------------------------------------------
@AREA:RU.OS.CMP
Мое почтение, доpогой господин All и все остальные господа!

[пpодолжение]

Beware: This program can crash your computer if the
operating system or hardware of same is buggy. User data may be lost.
.SH AUTHOR
George J Carrette. GJC\\@MITECH.COM
.SH VERSION
2.4 20-MAY-1994
===============================================================================
==========

===============================================================================
==========
/* crashme: Create a string of random bytes and then jump to it.
           crashme [+]<nbytes>[.inc] <srand> <ntrys> [nsub] [verboseness] */

char *crashme_version = "2.4 20-MAY-1994";

/*
*             COPYRIGHT (c) 1990-1994 BY        *
*  GEORGE J. CARRETTE, CONCORD, MASSACHUSETTS.  *
*             ALL RIGHTS RESERVED               *

Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of the author
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.

THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
HE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

A signal handler is set up so that in most cases the machine exception
generated by the illegal instructions, bad operands, etc in the procedure
made up of random data are caught; and another round of randomness may
be tried. Eventually a random instruction may corrupt the program or
the machine state in such a way that the program must halt. This is
a test of the robustness of the hardware/software for instruction
fault handling.

Note: Running this program just a few times, using total CPU time of
less than a few seconds SHOULD NOT GIVE YOU ANY CONFIDENCE in system
robustness. Having it run for hours, with tens of thousands of cases
would be a different thing. It would also make sense to run this
stress test at the same time you run other tests, like a multi-user
benchmark.

Comments may be addressed to the author at GJC@MITECH.COM

See the documentation in crashme.1 and READ.ME, or read this code for
a description of command line arguments to this program.

Version Date         Description
----------------------------------------------------------------------
1.0    early 1990   initial hack.
1.1    19-SEP-1990  added more signals and an alarm to abort looping.
1.2    25-JUN-1991  added [nsub] to vfork multiple subprocesses of self.
1.3    14-AUG-1991  +nbytes malloc option, and -nsub option.
1.4    29-AUG-1991  fix +nbytes (subproc). Add time-driven nprocs. SIGINT.
1.5     3-SEP-1991  added alarm subprocess monitor to vfork_main.
1.6     5-SEP-1991  some systems don't have vfork, so use fork by default.
1.7    25-SEP-1991  verboseness level, exit summary report.
1.8      -SEP-1991  address page protection issues on badboy.
1.9     6-AUG-1993  DECC(VMS)/WIN32/NT/Posix, #ifdef some SIGxxx.
2.0     7-SEP-1993  More extensive WIN32 conditionalization. record_note.
2.1     6-MAY-1994  Added "dot" syntax to NBYTES. Modularized castaway.
2.2     9-MAY-1994  __ALPHA && VMS version is now more interesting.
2.3    11-MAY-1994  Added _IBMRT2 and _POWER code.
2.4    20-MAY-1994  Added __hpux. Linux from jik@cam.ov.com.

Suggested test: At least let the thing run the length of your lunch break,
in this case 1 hour, 10 minutes, and 30 seconds.

 crashme +2000 666 100 1:10:30 2

Also, it may spend more time trapping and less time computing random bytes
by using these arguments:

 crashme +2000.80 666 100 1:10:30 2

                       CRASH REPORTS

Date,               Machine              Crashme        Reported
Crashme Ver   Make    Model OS Version   Arguments      by:        
------------------------------------------------------------------------------
10-JUL-90 1.0 SUN     4/110 4.1          1000 20 200    GJC@paradigm.com
10-JUL-90 1.0 SUN     4/280 4.0.3        1000 20 200    GJC@paradigm.com
31-JUL-90 1.0 DIGITAL DECstation 3100    100 10 10000   GAVRON@ARIZONA.EDU
31-JUL-90 1.0 IBM     RT                 100 10 10000   GAVRON@ARIZONA.EDU
1-AUG-90 1.0 DIGITAL DECstation 5000    10000 230 1000 hudgens@scri.fsu.edu
3-AUG-90 1.0 Alliant FX/2800                           SJA@SIRIUS.HUT.FI
27-JUN-91 1.2 SUN     4/110 4.1.1        10 1000 10     LPH@PARADIGM.COM   
27-JUN-91 1.2 SUN     4/110 4.1.1        1000 20 200 10 LPH@PARADIGM.COM   
29-JUN-91 1.2 SUN     4/40C 4.1.1        9 29748 5877 4 jon@uk.ac.oxford.robots
29-JUN-91 1.2 SUN     4/60 4.1.1         9 29748 5877 4 jon@uk.ac.oxford.robots
29-JUN-91 1.2 SUN     4/100 4.1.1        9 29748 5877 4 jon@uk.ac.oxford.robots
29-JUN-91 1.2 SUN     4/65 4.1.1         9 29748 5877 4 jon@uk.ac.oxford.robots
18-JUL-91 1.2 SGI     Iris4d Unix 3.3.2  1000 $$ 1000 4 tsacas@ilog.ilog.fr
29-JUL-91 1.1 IBM     RS/6000 AIX 1.3    script         brandis@inf.ethz.ch
5-SEP-91 1.6 IBM     RS/6000-320 AIX 3.1.5 +2000 666 50 40:00:00 LPH
26-SEP-91 1.8 Nixdorf Targon/35 TOS3.3   script         petri@ibr.cs.tu-bs.de
9-SEP-93 2.0 Microsoft WNT Build 511 i486 +1000 24131 50 gjc@mitech.com
3-FEB-94 1.8 HP710/HP-UX 9.00 +2000 666 100 2:00:00 5 UFOP@fpsp.fapesp.br
5-MAY-94 2.0 HP807/HPUX 9.00  4000 666 100 00:30:00 2 UFOP@fpsp.fapesp.br

Notes: Crashme V1.0 {1000 20 200} used to down the SUN 4/110. V1.2 does *not*
crash SUNOS 4.1.1 on the same arguments. Although using the extra argument
for subprocesses it will crash, with the console reporting:
"Bad Trap, Bad Kernel Read Fault, Bus error. Reboot"

Script means invoking file with many calls to crashme such as this:
#/bin/csh
crashme 1020 234 500 &
crashme 394 38484 5723 &
crashme 3784 474 474 &
crashme 437 4747 38 &
crashme 47848 4745 123 &
crashme 4747 4747 3463 &
crashme 474 46464 262 &
crashme 37 3644 3723 &
crashme 374 46464 22 &
crashme 3747 464 363 &
crashme 347 4747 44 &
crashme 37374 374 66 &
crashme 3737 474 4444 &

The 4-argument case of crashme could likely do as well as executing
a script.

*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <excpt.h>
#include <windows.h>
#else
#include <signal.h>
#include <setjmp.h>
#endif
#include <time.h>
#ifdef VMS
#include <processes.h>
#endif

#ifdef pyr
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/vmmac.h>
#define strchr index
#endif

#ifdef linux
#include <unistd.h>
#endif

typedef void (*BADBOY)();

BADBOY badboy;

long nbytes,nseed,ntrys;
long incptr = 0;
long offset = 0;
long next_offset = 0;
long malloc_flag = 0;
unsigned char *the_data;
char *note_buffer;
char *notes;

long verbose_level = 5;

void old_main(),copyright_note(),vfork_main(),badboy_loop();
void record_note();


FILE *logfile = NULL;

void record_note()
{char *logfilename;
if (!(logfilename = getenv("CRASHLOG"))) return;
if (!(logfile = fopen(logfilename,
        (strncmp(note_buffer,"Subprocess",10) == 0)
        ? "a" : "w")))
  {perror(logfilename);
   return;}
if (note_buffer[strlen(note_buffer)-1] != '\\n')
  strcat(note_buffer,"\\n");
fputs(note_buffer,logfile);
fclose(logfile);
logfile = NULL;}

void open_record()
{char *logfilename;
if (!(logfilename = getenv("CRASHLOG"))) return;
if (!(logfile = fopen(logfilename,"a")))
  {perror(logfilename);
   return;}}

void close_record()
{if (logfile)
  {fclose(logfile);
   logfile = NULL;}}

void note(level)
    long level;
{if (level > verbose_level) return;
strcat(note_buffer,"\\n");
fputs(note_buffer,stdout);
if (logfile)
  fputs(note_buffer,logfile);}

#ifndef WIN32
jmp_buf again_buff;
#endif

unsigned char *bad_malloc(n)
    long n;
{unsigned char *data;
data = (unsigned char *) malloc(n);
#ifdef pyr
if (mprotect(((int)data/PAGSIZ)*PAGSIZ, (n/PAGSIZ+1)*PAGSIZ,
      PROT_READ|PROT_WRITE|PROT_EXEC))
  perror("mprotect");
#endif
return(data);}

#ifndef WIN32

void again_handler(sig)
    int sig;
{char *ss;
switch(sig)
  {case SIGILL: ss =   " illegal instruction"; break;
#ifdef SIGTRAP
   case SIGTRAP: ss =   " trace trap"; break;
#endif
   case SIGFPE: ss =   " arithmetic exception"; break;
#ifdef SIGBUS
   case SIGBUS: ss =  " bus error"; break;
#endif
   case SIGSEGV: ss =  " segmentation violation"; break;
#ifdef SIGIOT
   case SIGIOT: ss = " IOT instruction"; break;
#endif
#ifdef SIGEMT
   case SIGEMT: ss = " EMT instruction"; break;
#endif
#ifdef SIGALRM
   case SIGALRM: ss = " alarm clock"; break;
#endif
   case SIGINT:  ss = " interrupt"; break;
   default: ss = "";}
sprintf(notes,"Got signal %d%s",sig,ss);
note(5);
longjmp(again_buff,3);}

void my_signal(sig, func)
    int sig;
    void (*func)();
{
#ifndef SA_ONESHOT
signal(sig, func);
#else
struct sigaction act;
act.sa_handler = func;
act.sa_mask = 0;
#ifdef linux
act.sa_restorer = 0;
#endif /* linux */
act.sa_flags = SA_NOMASK;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif
sigaction(sig, &act, 0);
#endif /* SA_ONESHOT */
}

set_up_signals()
{my_signal(SIGILL,again_handler);
#ifdef SIGTRAP
my_signal(SIGTRAP,again_handler);
#endif
my_signal(SIGFPE,again_handler);
#ifdef SIGBUS
my_signal(SIGBUS,again_handler);
#endif
my_signal(SIGSEGV,again_handler);
#ifdef SIGIOT
my_signal(SIGIOT,again_handler);
#endif
#ifdef SIGEMT
my_signal(SIGEMT,again_handler);
#endif
#ifdef SIGALRM
my_signal(SIGALRM,again_handler);
#endif
my_signal(SIGINT,again_handler);}

#endif

compute_badboy_1(n)
    long n;
{long j;
if (malloc_flag == 1)
  the_data = bad_malloc(n);
for(j=0;j<n;++j) the_data[j] = (rand() >> 7) & 0xFF;
if (nbytes < 0)
  {sprintf(notes,"Dump of %ld bytes of data",n);
   note(1);
   for(j=0;j<n;++j)
     {fprintf(stdout,"%3d",the_data[j]);
      if ((j % 20) == 19) putc('\\n',stdout); else putc(' ',stdout);}
   putc('\\n',stdout);}}

void proto_badboy()
{printf("Hello world.\\n");}

#if defined(__ALPHA) && defined(VMS) && !defined(NOCASTAWAY)
#include <pdscdef.h>
#endif

BADBOY castaway(dat)
    char *dat;
{
#if defined(VAX) && !defined(NOCASTAWAY)
 /* register save mask avoids bashing our callers locals */
 ((unsigned short *)dat)[0] = 0x0FFC;
#endif
#if defined(__ALPHA) && defined(VMS) && !defined(NOCASTAWAY)
 struct pdscdef *p,*b;
 p = (struct pdscdef *) proto_badboy;
 b = (struct pdscdef *) dat;
 memcpy(b,p,sizeof(struct pdscdef));
 b->pdsc$q_entry[1] = 0;
 b->pdsc$q_entry[0] = (int)&dat[sizeof(struct pdscdef)];
#endif
#if (defined(_IBMR2) || defined(_POWER)) && !defined(NOCASTAWAY)
 struct fdesc {void *fcn_addr; void *toc; void *linkage;} *p,*b;
 p = (struct fdesc *) proto_badboy;
 b = (struct fdesc *) dat;
 memcpy(b,p,sizeof(struct fdesc));
 b->fcn_addr = (void *) &dat[sizeof(struct fdesc)];
#endif
#if defined(__hpux) && defined(__hppa) && !defined(NOCASTAWAY)
 struct fdesc {void *fcn_addr; void *toc;} *p,*b;
 p = (struct fdesc *) proto_badboy;
 b = (struct fdesc *) dat;
 memcpy(b,p,sizeof(struct fdesc));
 b->fcn_addr = (void *) &dat[sizeof(struct fdesc)];
#endif
 return((BADBOY)dat);}

compute_badboy()
{long n;
n = (nbytes < 0) ? - nbytes : nbytes;
if (incptr == 0)
  {compute_badboy_1(n);
   badboy = castaway(the_data);}
else if ((next_offset == 0) || (next_offset > ((n * 90) / 100)))
  {compute_badboy_1(n);
   offset = 0;
   next_offset = offset + incptr;
   badboy = castaway(the_data);}
else
  {offset = next_offset;
   next_offset = offset + incptr;
   badboy = castaway(&the_data[offset]);}}

/* maybe add this code before invoking badboy. But it didn't seem
  to be needed when using +1000.
  FlushInstructionCache(GetCurrentProcess(),
                        the_data,(nbytes < 0) ? - nbytes : nbytes);
*/

try_one_crash()
{if (nbytes > 0)
  (*badboy)();
else if (nbytes == 0)
  while(1);}

char *subprocess_ind = "subprocess";

main(argc,argv)
    int argc; char **argv;
{long nsubs,hrs,mns,scs,tflag,j,m;
note_buffer = (char *) malloc(512);
notes = note_buffer;
if ((argc == 7) &&
    (strcmp(argv[6],subprocess_ind) == 0))
  {sprintf(note_buffer,"Subprocess %s: ",argv[4]);
   notes = note_buffer + strlen(note_buffer);
   verbose_level = atol(argv[5]);
   sprintf(notes,"starting");
   note(3);
   old_main(4,argv);}
else if (argc == 4)
  old_main(4,argv);
else if ((argc == 6) && ((strlen(argv[4]) == 0) ||
    (strcmp(argv[4],".") == 0)))
  {verbose_level = atol(argv[5]);
   old_main(4,argv);}
else if ((argc == 5) || (argc == 6))
  {if (argc == 6)
     verbose_level = atol(argv[5]);
   copyright_note(1);
   if (argc < 7)
     m = argc;
   else
     m = 6;
   strcpy(notes,"crashme");
   for(j=1;j<m;++j)
     {strcat(notes," ");
      strcat(notes,argv[j]);}
   note(1);
   record_note();
   if (strchr(argv[4],':'))
     {sscanf(argv[4],"%d:%d:%d",&hrs,&mns,&scs);
      tflag = 1;
      nsubs = (((hrs * 60) + mns) * 60) + scs;
      sprintf(notes,"Subprocess run for %d seconds (%d %02d:%02d:%02d)",
       nsubs, hrs / 24, hrs % 24,mns,scs);}
   else
     {tflag = 0;
      nsubs = atol(argv[4]);
      sprintf(notes,"Creating %d crashme subprocesses",nsubs);}
   note(1);
   vfork_main(tflag,nsubs,argv[0],argv[1],atol(argv[2]),argv[3]);}
else
  {sprintf(notes,
    "crashme [+]<nbytes>[.inc] <srand> <ntrys> [nsub] [verbose]");
   note(0);}}

void copyright_note(n)
    long n;
{sprintf(notes,"Crashme: (c) Copyright 1990-1994 George J. Carrette");
note(n);
sprintf(notes,"Version: %s",crashme_version);
note(n);}

void old_main(argc,argv)
    int argc;
    char **argv;
{char *ptr;
copyright_note(3);
nbytes = atol(argv[1]);
if (ptr = strchr(argv[1],'.'))
  incptr = atol(&ptr[1]);
if (argv[1][0] == '+') malloc_flag = 1;

[пpодолжение следует]

Всего вам наилучшего, доpогие господа!

--- FleetStreet 1.17+
* Origin: Bliss (2:5030/25.70)






<<<

архив dibr

>>>'