Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.unix-wizards Subject: Re: Bug iwith setjmp/longjmp on Vax Message-ID: <5683@utzoo.UUCP> Date: Fri, 7-Jun-85 13:10:47 EDT Article-I.D.: utzoo.5683 Posted: Fri Jun 7 13:10:47 1985 Date-Received: Fri, 7-Jun-85 13:10:47 EDT References: <44700008@gypsy.UUCP> Organization: U of Toronto Zoology Lines: 29 > This program was compiled under 4.2BSD on a VAX; it doesn't work the way it > should (I get a 'longjmp botch' message). If I compile the same exact > program on a Sun running 4.2BSD it works fine. I know that setjmp() and > longjmp() work on a Vax, but why is this simple program giving me a problem? > ... > main(){ > foo(); > longjmp(env, 1); > } > > foo(){ > mode = setjmp(env); > ... > } To quote the 4.2BSD setjmp(3) manual page (as well as all previous setjmp manual pages): [longjmp] returns in such a way that execution continues as if the call of setjmp had jsut returned ... to the function that invoked setjmp, *which must not itself have returned in the interim*. [emphasis added] In other words, your code is wrong. Put the setjmp in main(), or the longjmp in foo(), and it will be correct. It is only accidental that it works on some machines as it is. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry