From:	HENRY::IN%"cbosgd!okstate!usenet%seismo.css.gov%sri-kl.ARPA%relay.cs.net@rca.com" 29-MAR-1987 08:53
To:	mod-computers-vax@cbatt.att.com
Subj:	Submission for mod-computers-vax

Path: okstate!gregg
From: gregg%a.cs.okstate.EDU%relay.cs.net@rca.com
Newsgroups: mod.computers.vax
Subject: An example RWAST process
Keywords: RWAST VMS VAX
Message-ID: <1780@a.cs.okstate.edu>
Date: 25 Mar 87 16:29:28 GMT
Organization: Oklahoma State Univ., Stillwater
Lines: 295

I apologize for the length of this, but I thought it might be of general
interest.  There was recent discussion about processes in the RWAST state.
Below is a portion of a session with SDA after I got myself into RWAST while
using RTPAD and the tape drive at the same time.  The listing clearly shows
that the process is out of BIO quota.

This process, as the discussion mentioned, was not hogging the CPU, but did
have my outbound network port hung, as well as the directly connected terminal
that I was using at the time.  To make a long story short, STOP/ID would not
delete the process (as was also mentioned in the previous discussion) so I used
a macro program to alter the PCB, and the process just disappeared.  The code
is shown below for those that think it may be of use.  As the code shows, I
did not call any OS routines to notify the Scheduler of the PCB changes.  This
makes me wonder whether or not resources were being consumed.  Obviously
something took note of the changes, and freed the process from RWAST.

NOTE:  I do not recommend that you use this type of procedure to remove RWAST
processes.  There are too many unknowns to be certain that there will not be
any nasty side effects.  Instead, spend some time looking at active I/O bound
processes with SDA, and increase your UAF parameters to reasonable values.

I too would like to hear some general comments on why this type of thing is
not discovered by deadlock detection, etc...

-------------------------  MACRO program  ----------------------------------
;
;	This code borrowed from the SHOW OPERATORS code posted to this
;	group previously.
;
		.psect  data, noexe
 
		$pcbdef
		$ssdef
		.psect	code, exe,nowrt

		.entry	main,^m<r2,r3,r4,r5,r6,r7>

		$cmkrnl_s routin=kernal1	; Do the work
		pushl	r0			; Pass error code
		calls	#1,g^lib$stop		; Stop with message and trace
		ret
;
;	CMKRNL routine to alter the PCB
;
		.entry  kernal1,^m<r7,r8>
		moval   nocrash,(fp)		;Establish a kernal mode
						; excpetion handler.
;
;	Alter the PCB.  BIOLM is increased by one to account for the increase
;	by one of BIOCNT.  The magical addres ^x80133f50, is shown in the output
;	output of the SDA command, SHOW PROCESS, as the processes PCB address.
;
		movl	#^x80133f50,r7

;	Increase the Buffered I/O quota limit by one

		cvtwl	PCB$W_BIOLM(r7),r8
		incl	r8
		cvtlw	r8,PCB$W_BIOLM(r7)

;	Increase the number of available Buffered I/O requests

		cvtwl	PCB$W_BIOCNT(r7),r8
		incl	r8
		cvtlw	r8,PCB$W_BIOCNT(r7)

		ret	
;
		.sbttl  KMODE_EXCEPTION_HANDLER
;
; Provides some reasonable safeguard against crashing your system.
; (From Bruce Elliot, thanks.)
;
reason:
		.long   80
		.address        10$
10$:
		.blkb   80
 
control_reason:
		.ascid  /Access violation at VA = !XL & PC = !XL/
 
		.entry  nocrash,^m<r2,r3>
		movl    4(ap),r2                ;Get address of signal array
		cmpl    4(r2),#ss$_accvio       ;if it's an access violation,
						; display and get out.
		bneq    not_access_violation

		$fao_s  outbuf=reason,-
			outlen=reason,-
			ctrstr=control_reason,-
			p1=12(r2),p2=16(r2)

		pushal  reason
		calls   #1,g^lib$put_output     ;Display the reason for the crash.
		$exit_s                         ;kill the process
 
not_access_violation:
		movl    #ss$_resignal,r0        ;Pass the buck
		ret
 
		.END MAIN


-------------------------  SDA logfile  ------------------------------------
$ ana/system
SDA> set log sys$login:stuck.log
SDA> show summary
Current process summary
-----------------------
 Extended Indx Process name    Username    State Pri   PCB      PHD    Wkset
-- PID -- ---- --------------- ----------- ----- --- -------- -------- -----
 00002AE0 0020 Moviemaker      GREGG        RWAST  8 80133F50 802F1800   452

SDA> set proc/index=2ae0
SDA> show proc
Process index: 0020   Name: Moviemaker   Extended PID: 00002AE0
---------------------------------------------------------------
Process status:  02040001   RES,PHDRES

PCB address              80133F50    JIB address              80171900
PHD address              802F1800    Swapfile disk address    01000A21
Master internal PID      00AB0020    Subprocess count                1
Internal PID             00AB0020    Creator internal PID     00000000
Extended PID             00002AE0    Creator extended PID     00000000
State                       RWAST    Termination mailbox          0000
Current priority               10    AST's enabled                KESU
Base priority                   5    AST's active                 U   
UIC                [00101,000003]    AST's remaining                 6
Mutex count                     0 -->Buffered I/O count/limit        0/10<--
Waiting EF cluster              0    Direct I/O count/limit         10/10
Starting wait time       1A001A1A    BUFIO byte count/limit      16481/17974
Event flag wait mask     00000001    # open files allowed left      26
Local EF cluster 0       E0000002    Timer entries allowed left     20
Local EF cluster 1       E0000000    Active page table count         0
Global cluster 2 pointer 00000000    Process WS page count         279
Global cluster 3 pointer 00000000    Global WS page count          173
SDA> show stack/user
Process stacks
--------------
USER stack:

		7FF1BEB4  00000000	
		7FF1BEB8  00000000	
		7FF1BEBC  00000000	
		7FF1BEC0  00000000	
		7FF1BEC4  7FF1BF4C	
		7FF1BEC8  00000000	
		7FF1BECC  2FFC0000	
		7FF1BED0  00000000	

	 SP =>  7FF1BED4  00000000	
		7FF1BED8  2FFC0000	
		7FF1BEDC  7FF1BF5C	
		7FF1BEE0  7FF1BF44	
		7FF1BEE4  00003DF2	
		7FF1BEE8  800021BC	SCH$GQ_HIBWQ
		7FF1BEEC  7FF9233B	
		7FF1BEF0  80133F50	
		7FF1BEF4  7FFE64B4	MMG$IMGHDRBUF+0B4
		7FF1BEF8  00000000	
		7FF1BEFC  00000001	
		7FF1BF00  7FFED052	
		7FF1BF04  7FFED25A	
		7FF1BF08  7FFEDDD4	
		7FF1BF0C  7FFE33DC	CTL$AG_CLIDATA+180
		7FF1BF10  0000000C	
		7FF1BF14  00000000	
		7FF1BF18  000000B0	
		7FF1BF1C  00000031	
		7FF1BF20  00029E9C	
		7FF1BF24  00003E10	
		7FF1BF28  00029E90	
		7FF1BF2C  00029EA4	
		7FF1BF30  00000050	
		7FF1BF34  00000000	
		7FF1BF38  00000000	
		7FF1BF3C  00000000	
		7FF1BF40  00000000	
		7FF1BF44  00000000	
		7FF1BF48  20040000	
		7FF1BF4C  7FF1BF78	
		7FF1BF50  7FF1BF64	
		7FF1BF54  00003E33	
		7FF1BF58  800021BC	SCH$GQ_HIBWQ
		7FF1BF5C  00000001	
		7FF1BF60  00029E90	
		7FF1BF64  00000000	
		7FF1BF68  00000000	
		7FF1BF6C  7FF1BFB4	
		7FF1BF70  7FF1BF90	
		7FF1BF74  80009E5E	EXE$ASTRET
		7FF1BF78  00000005	
		7FF1BF7C  00029E90	
		7FF1BF80  00000023	
		7FF1BF84  00000000	
		7FF1BF88  7FFEDF8A	SYS$HIBER+002
		7FF1BF8C  03C00000	
		7FF1BF90  00000000	
		7FF1BF94  203C0000	
		7FF1BF98  7FF1BFCC	
		7FF1BF9C  7FF1BFB8	
		7FF1BFA0  00005158	
		7FF1BFA4  0000000F	
		7FF1BFA8  7FF9233B	
		7FF1BFAC  7FFE640C	MMG$IMGHDRBUF+00C
		7FF1BFB0  7FFE64B4	MMG$IMGHDRBUF+0B4
		7FF1BFB4  00000000	
		7FF1BFB8  00000000	
		7FF1BFBC  20000000	
		7FF1BFC0  7FF1BFFC	
		7FF1BFC4  7FF1BFE8	
		7FF1BFC8  7FF9267B	
		7FF1BFCC  00000006	
		7FF1BFD0  7FFE643C	MMG$IMGHDRBUF+03C
		7FF1BFD4  7FF9702C	
		7FF1BFD8  7FFE640C	MMG$IMGHDRBUF+00C
		7FF1BFDC  7FFE64B4	MMG$IMGHDRBUF+0B4
		7FF1BFE0  01000028	
		7FF1BFE4  00000000	
		7FF1BFE8  800212C0	EXE$CATCH_ALL
		7FF1BFEC  20000000	
		7FF1BFF0  00000000	
		7FF1BFF4  00000000	
		7FF1BFF8  7FF925DD	
		7FF1BFFC  00000000	
		7FF1C000  00000000	

SDA> show stack/exe
Process stacks
--------------
EXECUTIVE stack:

		7FFE9DE0  7FFB5C08	
		7FFE9DE4  7FFE0248	PIO$GW_PIOIMPA
		7FFE9DE8  00000005	
		7FFE9DEC  7FFB5D28	
		7FFE9DF0  00000001	
		7FFE9DF4  00000000	
		7FFE9DF8  7FFEE130	SYS$SETPRV+030
		7FFE9DFC  03C00000	

	 SP =>  (STACK IS EMPTY)
SDA> show stack/kern
Process stacks
--------------
Current operating stack (KERNEL):

		7FFE7DBC  00000001	
		7FFE7DC0  00000001	
		7FFE7DC4  80133F8A	
		7FFE7DC8  00000010	
		7FFE7DCC  80133F50	
		7FFE7DD0  80134A40	
		7FFE7DD4  8000A788	EXE$MULTIQUOTA+032
		7FFE7DD8  00C00001	

	 SP =>  7FFE7DDC  800099B9	EXE$QIO+09A
		7FFE7DE0  80133F8A	
		7FFE7DE4  00000000	
		7FFE7DE8  00000000	
		7FFE7DEC  7FF1BF10	
		7FFE7DF0  7FF1BED4	
		7FFE7DF4  8000FDCE	EXE$CMODEXEC+176
		7FFE7DF8  7FFEDFCE	SYS$QIO+006
		7FFE7DFC  03C00000	
SDA> show stack/inter
Process stacks
--------------
INTERRUPT stack:

SDA> show stack/super
Process stacks
--------------
SUPERVISOR stack:

		7FFED02E  00000000	
		7FFED032  00000000	
		7FFED036  00000000	
		7FFED03A  00000000	
		7FFED03E  0000000F	
		7FFED042  7FF9233B	
		7FFED046  7FF925D7	
		7FFED04A  03C00000	

	 SP =>  7FFED04E  7FF8C3B1	
		7FFED052  00000200	BUG$_IVWSETLIST
		7FFED056  7FFED05A	
		7FFED05A  7FFED042	
		7FFED05E  00000026	
		7FFED062  46464154	
		7FFED066  52475B3A	
		7FFED06A  5D474745	

    Press RETURN for more.
