Issue1784

classification
Title: PythonInterpreter.initialize hangs, if System.in.read() is blocking, in a java-on-java child process, on a Windows Server 2003 VMWare
Type: Severity: normal
Components: Core Versions: Jython 2.5
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: amak Nosy List: Daniel Tripp, amak, fwierzbicki, kbrowder, zyasoft
Priority: normal Keywords:

Created on 2011-07-28.01:26:59 by Daniel Tripp, last changed 2014-06-19.06:22:56 by zyasoft.

Files
File name Uploaded Description Edit Remove
Parent.java Daniel Tripp, 2011-07-28.01:26:59
Messages
msg6587 (view) Author: Daniel Tripp (Daniel Tripp) Date: 2011-07-28.01:26:59
Hello.  I hope this is the correct place to report this.  

Like the subject says, I ran into some strange behaviour.  The attached code reproduces this.  Since it is creating a child java process, it assumes some things, such as that jython.jar is in the current directory, as are the Parent / Child class files.

If I run that code on my Vista machine, it exits normally.  If I run it on my Windows Server 2003 VM, the child process never exits.

Attaching to the hung process with a debugger reveals that the main thread is hung in the stack below. 

I would test it on more machines but I don't have the time right now.

sun.security.provider.NativeSeedGenerator.nativeGenerateSeed(Native Method)
sun.security.provider.NativeSeedGenerator.<init>(NativeSeedGenerator.java:28)
sun.security.provider.SeedGenerator.<clinit>(SeedGenerator.java:81)
sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:170)
java.security.SecureRandom.nextBytes(SecureRandom.java:433)
java.security.SecureRandom.next(SecureRandom.java:455)
java.util.Random.nextLong(Random.java:284)
java.io.File.generateFile(File.java:1682)
java.io.File.createTempFile(File.java:1791)
java.io.File.createTempFile(File.java:1828)
com.kenai.jffi.Init.loadFromJar(Init.java:119)
com.kenai.jffi.Init.load(Init.java:64)
com.kenai.jffi.Foreign$InstanceHolder.getInstanceHolder(Foreign.java:35)
com.kenai.jffi.Foreign$InstanceHolder.<clinit>(Foreign.java:31)
com.kenai.jffi.Foreign.getInstance(Foreign.java:81)
com.kenai.jffi.Internals.getErrnoSaveFunction(Internals.java:30)
com.kenai.jaffl.provider.jffi.StubCompiler.getErrnoSaveFunction(StubCompiler.java:85)
com.kenai.jaffl.provider.jffi.StubCompiler.<clinit>(StubCompiler.java:35)
com.kenai.jaffl.provider.jffi.AsmLibraryLoader.generateInterfaceImpl(AsmLibraryLoader.java:161)
com.kenai.jaffl.provider.jffi.AsmLibraryLoader.loadLibrary(AsmLibraryLoader.java:125)
com.kenai.jaffl.provider.jffi.Provider.loadLibrary(Provider.java:31)
com.kenai.jaffl.provider.jffi.Provider.loadLibrary(Provider.java:25)
com.kenai.jaffl.Library.loadLibrary(Library.java:76)
org.python.posix.POSIXFactory$WindowsLibCProvider$SingletonHolder.<clinit>(POSIXFactory.java:127)
org.python.posix.POSIXFactory$WindowsLibCProvider.getLibC(POSIXFactory.java:131)
org.python.posix.BaseNativePOSIX.<init>(BaseNativePOSIX.java:29)
org.python.posix.WindowsPOSIX.<init>(WindowsPOSIX.java:115)
org.python.posix.POSIXFactory.loadWindowsPOSIX(POSIXFactory.java:87)
org.python.posix.POSIXFactory.loadPOSIX(POSIXFactory.java:36)
org.python.posix.LazyPOSIX.loadPOSIX(LazyPOSIX.java:28)
org.python.posix.LazyPOSIX.posix(LazyPOSIX.java:24)
org.python.posix.LazyPOSIX.isatty(LazyPOSIX.java:135)
org.python.core.io.StreamIO.isatty(StreamIO.java:234)
org.python.core.io.BufferedIOMixin.isatty(BufferedIOMixin.java:90)
org.python.core.io.TextIOBase.isatty(TextIOBase.java:175)
org.python.core.PyFile.file_isatty(PyFile.java:485)
org.python.core.PyFile.isatty(PyFile.java:480)
org.python.core.PySystemState.initEncoding(PySystemState.java:245)
org.python.core.PySystemState.<init>(PySystemState.java:189)
org.python.core.PySystemState.doInitialize(PySystemState.java:890)
org.python.core.PySystemState.initialize(PySystemState.java:800)
org.python.core.PySystemState.initialize(PySystemState.java:750)
org.python.core.PySystemState.initialize(PySystemState.java:743)
org.python.util.PythonInterpreter.initialize(PythonInterpreter.java:57)
Parent$Child.main(Parent.java:90)

Regards, 

- Dan
msg7077 (view) Author: Kevin Browder (kbrowder) Date: 2012-05-02.13:08:24
I also encountered this issue as well using the run-jetty-run plugin with jetty 8.1.2.v20120308 and Jython 2.5.2 with Modjy on Windows XP.  My solution was to create a class that inherits from ModjyJServlet and does a System.setIn to a dummy input stream (with read always returning -1) before calling super.init() and then reset the input stream to the original when done with everything.
msg7759 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-25.21:31:16
Alan, do you have any insight on this?
msg7769 (view) Author: Alan Kennedy (amak) Date: 2013-02-25.22:20:55
I think this may be caused by trying to read too much entropy from the NativeSeedGenerator, which is where the code appears to hang.

There is a java report for this

NativeSeedGenerator is making 8192 byte read requests from entropy pool on each init.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6998583

Which appears to be fixed in Java 6 update 24, which was released around the time the user reported the issue.

Please can the user retest with a version after Java 6 update 24?
msg8726 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.06:22:56
Closing out given the fix in the JDK and no response from OP
History
Date User Action Args
2014-06-19 06:22:56zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg8726
nosy: + zyasoft
2013-02-25 22:20:55amaksetassignee: amak
messages: + msg7769
2013-02-25 21:31:16fwierzbickisetpriority: normal
nosy: + fwierzbicki, amak
messages: + msg7759
versions: + Jython 2.5, - 2.5.2
2012-05-02 13:08:24kbrowdersetnosy: + kbrowder
messages: + msg7077
2011-07-28 01:26:59Daniel Trippcreate