From owner-freebsd-java@FreeBSD.ORG Sat Oct 25 14:12:26 2003 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E49C316A4B3; Sat, 25 Oct 2003 14:12:26 -0700 (PDT) Received: from enteljoven2.enteljoven.cl (enteljoven2.enteljoven.cl [164.77.63.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id A0E1743F93; Sat, 25 Oct 2003 14:12:25 -0700 (PDT) (envelope-from rdeiriar@spock.cl) Received: from spock.cl (CM600-lconC1-16-33.cm.vtr.net [200.104.16.33]) (AUTH: CRAM-MD5 roberto@spock.cl) by enteljoven2.enteljoven.cl with esmtp; Sat, 25 Oct 2003 18:12:38 -0300 Message-ID: <3F9AE749.7050307@spock.cl> Date: Sat, 25 Oct 2003 18:12:41 -0300 From: Roberto de Iriarte User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031023 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-mozilla@freebsd.org, freebsd-java@freebsd.org References: <20031023122839.A75570@phantom.cris.net> <20031023104836.GB7723@azrael.xs4all.nl> <20031025160103.GC7723@azrael.xs4all.nl> <20031025204029.A2230@phantom.cris.net> In-Reply-To: <20031025204029.A2230@phantom.cris.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: jdk14 fork() problem fix X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2003 21:12:27 -0000 [Crossposted to freebsd-mozilla@freebsd.org and freebsd-java@freebsd.org] I have experienced a similar problem when running flashpluginwrapper-20031006 (A wrapper libraryto allow the linux plugin for Macromedia Flash to be used with native mozilla), as well as the native 1.4.1 patchlevel 4 plugin with Mozlla, with libc_r (The problem does not manifest itself under 5-CURRENT with libkse). I've been unable to reproduce the bug with your patch applied, Regards and thanks for everything. Roberto. Alexey Zelkin wrote: hi, On Sat, Oct 25, 2003 at 06:01:03PM +0200, Remco van 't Veer wrote: >> I've been running ant (with external processes like jikes and >> javadoc), compiling jsps and doing other stuff which fork >> processes with a jvm including your patch but I can't reproduce >> to problem. This ofcourse only proves my inability to repeat >> this bug and not that the problem has been fixed.. The hanging >> processes actually happend quiet often so I can say is much >> harder to reproduce. > > If problem persist then you'll notice processes which eats much of system time and not exiting without SIGKILL. >> I ran these tests on my FreeBSD 4.8 system. Does you remark >> about kse and thr mean this problem does not occure on systems >> using these technologies? > > No. This problem is libc_r specific. >> Anyway, I am really happy with this patch and hope it will be >> included in the next version. Thank you for your fantastic work. > > Sure. Thank you for report! >> On Thu, Oct 23, 2003 at 12:48, Remco van 't Veer wrote: >> > > >>> > Thanx! I have a new compile running right now. It will take >>> > more than 10 hours to finish on my poor P3 so I hope to have some >>> > test results for you tomorrow. >>> > >>> > Remco >>> > >>> > >>> > On Thu, Oct 23, 2003 at 12:28, Alexey Zelkin wrote: >>> > >> >> >>>> > > hi, >>>> > > >>>> > > This is an intermediate version of fix of jdk fork problem (i.e. >>>> > > Runtime.getRuntime().exec() and friends). >>>> > > >>>> > > It does affect only people who use libc_r (kse and thr should not >>>> > > be affected). >>>> > > >>>> > > Please try this one and report me if it fixes problems for you. >>>> > > >>>> > > PS: If you are rebuilding already built jdk (i.e. object files are >>>> > > already compiled) remove 'control/build/bsd-i586/tmp/java/java.lang' directory >>>> > > before restarting of build. >>>> > > >>>> > > Index: UNIXProcess_md.c.bsd >>>> > > =================================================================== >>>> > > RCS file: /home/jdk14-cvs/jdk142-src/j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd,v >>>> > > retrieving revision 1.2 >>>> > > diff -u -r1.2 UNIXProcess_md.c.bsd >>>> > > --- UNIXProcess_md.c.bsd 15 Oct 2003 15:49:39 -0000 1.2 >>>> > > +++ UNIXProcess_md.c.bsd 23 Oct 2003 10:20:48 -0000 >>>> > > @@ -22,6 +22,12 @@ >>>> > > #include >>>> > > #include >>>> > > >>>> > > +#if defined(__FreeBSD__) >>>> > > +#include >>>> > > +#include >>>> > > +#include >>>> > > +#endif >>>> > > + >>>> > > /* path in the environment */ >>>> > > static char **PATH = 0; >>>> > > /* effective uid */ >>>> > > @@ -228,6 +234,61 @@ >>>> > > } >>>> > > } >>>> > > >>>> > > +#if defined(__FreeBSD__) >>>> > > + >>>> > > +extern pid_t __sys_fork(void); >>>> > > + >>>> > > +static pid_t >>>> > > +jdk_fork_wrapper() >>>> > > +{ >>>> > > + pid_t resultPid; >>>> > > +#if (__FreeBSD_version < 5) >>>> > > + static int is_libc_r = -1; >>>> > > + void *funcref; >>>> > > + >>>> > > + if (is_libc_r == -1) { >>>> > > + is_libc_r = 1; >>>> > > + >>>> > > + /* >>>> > > + * BSDNOTE: Check for loaded symbols. >>>> > > + * >>>> > > + * If "_thr_critical_enter" is found assume we are using 'libthr'. >>>> > > + * If _kse_critical_enter is found assume we are using 'libkse'. >>>> > > + * Otherwise we are using libc_r. >>>> > > + * >>>> > > + * If libc_r is loaded, use fork system call drectly to avoid >>>> > > + * problems with using protected pages. >>>> > > + * >>>> > > + * --phantom >>>> > > + */ >>>> > > + funcref = dlsym(RTLD_DEFAULT, "_kse_critical_enter"); >>>> > > + if (funcref != NULL) >>>> > > + is_libc_r = 0; >>>> > > + else { >>>> > > + funcref = dlsym(RTLD_DEFAULT, "_thr_critical_enter"); >>>> > > + if (funcref != NULL) >>>> > > + is_libc_r = 0; >>>> > > + } >>>> > > + } >>>> > > + >>>> > > + if (is_libc_r == 0) { >>>> > > + /* Not a libc_r */ >>>> > > + resultPid = fork(); >>>> > > + } else { >>>> > > +#endif /* __FreeBSD_version < 5 */ >>>> > > + pthread_suspend_all_np(); >>>> > > + resultPid = __sys_fork(); >>>> > > + if (resultPid != 0) >>>> > > + /* leave child in single threading mode */ >>>> > > + pthread_resume_all_np(); >>>> > > +#if (__FreeBSD_version < 5) >>>> > > + } >>>> > > +#endif /* __FreeBSD_version < 5 */ >>>> > > + >>>> > > + return resultPid; >>>> > > +} >>>> > > +#endif /* __FreeBSD__ */ >>>> > > + >>>> > > JNIEXPORT jint JNICALL >>>> > > Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, >>>> > > jobject process, >>>> > > @@ -335,8 +396,12 @@ >>>> > > if (path != NULL) { >>>> > > cwd = (char *)JNU_GetStringPlatformChars(env, path, NULL); >>>> > > } >>>> > > - >>>> > > + >>>> > > +#if defined(__FreeBSD__) >>>> > > + resultPid = jdk_fork_wrapper(); >>>> > > +#else >>>> > > resultPid = fork(); >>>> > > +#endif >>>> > > >>>> > > if (resultPid < 0) { >>>> > > char errmsg[128]; >>>> > > _______________________________________________ >>>