🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Alan Lee Wendt Fri, 20 May 1988 20:17
Venix-86 sbrk() wraps and dumps core.
#784
Author: Alan Lee Wendt
Date: Fri, 20 May 1988 20:17
54 lines
1609 bytes
Problem:    sbrk wraps the break, returning a low number.

Symptom:    Segmentation violations.  On my system attempts to
            backtrace the problem in the debugger crash the system.

System:     80286 Venix V Rev 2.2, but examine other Sys V
	    in case it's generic.

Reproduce:  Set the break to 65022 with a series of sbrk calls.
	    Then do sbrk(526).  My system will set the new break
	    to 12.

Fix:        I added a jump on no-carry (jnb) around some code that
	    sets the errno to ENOMEM and returns -1.  If the addition
	    to get the new break wraps, it will set the carry and
	    fall into the error case.
	    You'll need to disassemble brk.o in /lib/libc.  The
	    routine brk is also in brk.o but is not shown here
	    because it doesn't need changes.

	    Apologies for the hard constants.

Fixer:      Alan Wendt


	.globl	_end
	.comm	_errno,2
	.data
	.even
_loc:	.word	_end

	.text

	.globl	_sbrk
_sbrk:	push	bp
	mov	bp,sp
	mov	bx,#17
	mov	ax,*4(bp)
	add	ax,_loc
	jnb	_try			*new
	mov	_errno,*12		*new
	mov	ax,*-1			*new
	j	_out1			*new
_try:					*new
	int	241
	jcxz	_ok1
	mov	_errno,cx
	j	_out1
_ok1:	mov	bx,_loc
	mov	ax,bx
	add	bx,*4(bp)
	mov	_loc,bx
_out1:	pop	bp
	ret
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads