You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2007/02/13 23:25:36 UTC

DO NOT REPLY [Bug 41603] New: - external jython classes are not thread-safe

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603

           Summary: external jython classes are not thread-safe
           Product: Ant
           Version: 1.7.0RC1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: josborne@exstream.com


file threadtest.py:
class threadtester:
  def __init__( self, list=[] ):
    self.list = list


file threadtest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="unix-build-all" name="comp-all">

  <target name="unix-build-all">
    <parallel failonany='false'>
      <antcall target="testtarget">
        <param name="sleep" value="1" />
      </antcall>
      <antcall target="testtarget">
        <param name="sleep" value="2" />
      </antcall>
      <antcall target="testtarget">
        <param name="sleep" value="3" />
      </antcall>
      <antcall target="testtarget">
        <param name="sleep" value="4" />
      </antcall>
      <antcall target="testtarget">
        <param name="sleep" value="5" />
      </antcall>
    </parallel>
  </target>

  <target name="testtarget">
    <sleep seconds="${sleep}"/>
    <threadtest></threadtest>
  </target>

  <scriptdef name="threadtest" language="jython">
       <attribute name="key"/>
<![CDATA[
from threadtest import *

test = threadtester()
test.list.append("test")
project.log("Beginning thread test...")
for i in test.list:
  project.log(i)
project.log("Ending thread test.\n\n")

]]>
  </scriptdef>

</project>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 41603] - external jython classes are not thread-safe

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603


josborne@exstream.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW




------- Additional Comments From josborne@exstream.com  2007-02-14 06:25 -------
I was not sure if this was an ant issue or a jython issue so I am reporting the 
bug to both teams.   The interesting thing is that if the threadtester class is 
included directly in threadtest.xml then test is only printed once for each 
run.  Calling threadtest([]) does indeed remedy the problem, but I have run 
into several issues now where threads are overwriting one another's memory 
within scriptdef tasks and this definitely seems to be a problem.

I suppose the question is whether jython is to blame or the jvm implementation?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 41603] - external jython classes are not thread-safe

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603





------- Additional Comments From stevel@apache.org  2007-02-14 07:14 -------
I dont know what we will do about this. I believe we could (a) link it to the
other bug about script thread safety and (b) check how other script langauges
behave.

What I will do right now is highlight that parallel is an exceedingly dangerous
thing to do. the only 95% safe activity you can do in it is run external stuff
using <parallel> or <exec>. It is not meant to be a way to speed up ant.

there is a small hint of this in the docs, but I have added a big warning to the
front that states more clearly, "play games with parallel and you get to debug
the thread safety of the classes you use"

<p><b>Warning:</b> While the Ant core is believed to be thread safe, no such 
    guarantees are made about tasks, which are not tested for thread safety during
    ant's test process. 
    Third party tasks may or may not be thread safe, and some of Ant's core
tasks, such as
    &lt;javac&gt; are definitely not re-entrant. This is because they use
libraries that
    are not designed to be used in a multithreaded environment.
</p>
<p>
    The primary use case for &lt;parallel&gt; is to run external programs
    such as an application server, and the JUnit or TestNG test suites at the
    same time. Anyone trying to run large Ant task sequences in parallel, such
    as javadoc and javac at the same time, is implicitly taking on the task
    of identifying and fixing all concurrency bugs in Ant and its tasks.
</p>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 41603] - external jython classes are not thread-safe

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603





------- Additional Comments From josborne@exstream.com  2007-02-14 06:28 -------
also consider the following script.  It prints a seemingly random number of 
'test' lines each time and occasionally errors out altogether:


<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="unix-build-all" name="comp-all">

  <target name="unix-build-all">
    <parallel failonany='false'>
      <threadtest></threadtest>
      <threadtest></threadtest>
      <threadtest></threadtest>
      <threadtest></threadtest>
    </parallel>
  </target>

  <scriptdef name="threadtest" language="jython">
       <attribute name="key"/>
<![CDATA[
from threadtest import *

test = threadtester()
test.list.append("test")
project.log("Beginning thread test...")
for i in test.list:
  project.log(i)
project.log("Ending thread test.\n\n")

]]>
  </scriptdef>

</project>


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 41603] - external jython classes are not thread-safe

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603


jkf@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From jkf@apache.org  2007-02-13 15:30 -------
First of all, why would the ant development team be responsible for the thread
safety of external jython classes?

When running your example i get the following output (reproducible)

Buildfile: build2.xml

main2:

testtarget:

testtarget:

testtarget:

testtarget:

testtarget:
Beginning thread test...
test
Ending thread test.


Beginning thread test...
test
test
Ending thread test.


Beginning thread test...
test
test
test
Ending thread test.


Beginning thread test...
test
test
test
test
Ending thread test.


Beginning thread test...
test
test
test
test
test
Ending thread test.



BUILD SUCCESSFUL
Total time: 5 seconds

Which seems ok from the provided scripts, when comparing to the following scripts:
test = threadtester()
test.list.append("test")
test = threadtester()
test.list.append("test")
test = threadtester()
test.list.append("test")
test = threadtester()
test.list.append("test")
test = threadtester()
test.list.append("test")
for i in test.list:
  project.log(i)

which also prints the line "test" 5 times

when creating test = threadtester([]) test is only printed once each time, so
this really seems (to the innocent bystander at least) to be the normal
behaviour for the language, and not dependent on threading or not.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 41603] - external jython classes are not thread-safe

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41603>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41603


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Additional Comments From peterreilly@apache.org  2007-03-14 03:32 -------
Marking as "WONTFIX", it probally should be "INVALID"
based on the comments.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org