Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!caip!clyde!burl!ulysses!cbosgd!ucbvax!CGL.UCSF.EDU!conrad From: conrad@CGL.UCSF.EDU (Conrad Huang) Newsgroups: mod.computers.vax Subject: VAX C help needed Message-ID: <8609060037.AA23826@cgl.ucsf.edu> Date: Fri, 5-Sep-86 20:37:57 EDT Article-I.D.: cgl.8609060037.AA23826 Posted: Fri Sep 5 20:37:57 1986 Date-Received: Sat, 6-Sep-86 20:33:24 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 32 Approved: info-vax@sri-kl.arpa I've been trying to port ex/vi from 4.3BSD Unix to 4.3VMS (with VAX C V2.0-003) for the past two weeks. Ex/vi is a Unix editor written entirely in C. One of the problems that I ran into while porting it was getting access violations at strange places. Ex/vi uses sbrk() and brk() exclusively for memory management (there is no reference anywhere to malloc(), free(), etc). It also uses two files for temporary storage. The sequence of event that lead up to the access violation is as follows: open(temp_file_1) sbrk(xxx); end1 = sbrk(0); ... lots of processing ... open(temp_file_2) ... more processing with I/O to temp_file_2... end2 = sbrk(yyy); ... copy data to "end1" -> ACCESS VIOLATION VIRTUAL ADDRESS = end1 If I do not use temp_file_2 (delete the open and I/O), then I do *not* get the access violation. I suspect the problem is that opening the second file somehow allocates memory starting at "end1" and makes it somehow outside the legal addressing space. Would anyone who knows about VAX C innards please let me know whether this is correct? I'm completely baffled as to how to fix this problem and would greatly appreciate any pointers. Thanks, Conrad PS I've moved the second "open" call around in the code. It doesn't matter where it appears. As long as the second "open" is present, the program bombs out with an ACCESS VIOLATION sooner or later.