Menu

#670 Crash in PMDTask due to multithreading

closed
pmd (543)
5
2016-10-30
2007-04-16
No

Paste this into PMDs build.xml:

<target name="pmd" description="Runs PMD" depends="copy, compile">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="dependencies.path"/>
<pmd targetjdk="1.5" rulesetfiles="${dir.rulesets}\\migrating_to_15.xml" shortFilenames="true">
<formatter type="text" toConsole="true"/>
<fileset dir="${dir.src}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>

Running this task from Eclipse results in a:

java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)

The origin of this exception is the executor.shutdown() line in PMD.java. It appears that ending the ExecutorService requires permissions which are not granted by default (at least in Eclipse). I've hacked something which only partially fixes the problem (see attachment), so I decided against committing it. Instead, I'll do a revert of PMDTask and a partial revert of Formatter, which solves the problem (no more Ant multithreading though). Since I don't think we want to ship this bug, that seems the best solution to me.

Xavier, perhaps you can take a look at this as well?

Related

Issues: #1025
Issues: #670

Discussion

  • Wouter Zelle

    Wouter Zelle - 2007-04-16

    Partial workaround (still a thread leak)

     
  • Xavier Le Vourch

    Logged In: YES
    user_id=1373398
    Originator: NO

    Hi Wouter,

    I had a look at the bug and cannot reproduce it on my system but I see there's a possible problem with permissions.

    Before trying to fix it and still allow multithreading, I'd like to reproduce the crash so I'd like you to give me more info on your setup (OS, jvm version, eclipse version, ...).

    When I run the task from the ant view in Eclipse, it works fine with the following setup: Linux CentOS 5, Sun jdk 1.6.0_01, eclipse 3.2.2. I haven't done any special customization in Eclipse yet.

    You can contact me directly by email if it's easier.

    Xavier

     
  • Xavier Le Vourch

    Logged In: YES
    user_id=1373398
    Originator: NO

    I found out more info from a Sun forum where someone said it was fixed in 1.6:

    http://forum.java.sun.com/thread.jspa?threadID=775305&tstart=270

    After looking at that thread, I tested with jdk 1.5 and I can reproduce it then.

    So I guess the "solution" is to update to 1.6... Seriously, I'll try to find a real workaround.

    Xavier

     
  • Wouter Zelle

    Wouter Zelle - 2007-04-18

    Logged In: YES
    user_id=555114
    Originator: YES

    The fix seems to be in java.security.ProtectionDomain. That class performs the actual permission check. In Java 6, if no explicit permissions are set, the constructor sets a hasAllPerm boolean to true. That boolean is used during the permissions check to allow everything. In Java 5, this is missing completely. So Java 6 is lenient by default, while Java 5 is strict.

    Anyway, it seems that we need to set the permissions explicitly somehow.

     
  • Xavier Le Vourch

    Logged In: YES
    user_id=1373398
    Originator: NO

    runtime test to see if ExecutorService.shutdown() throws an exception added. If that's the case, code is executed in main thread only.

    Xavier

     
  • Anonymous

    Anonymous - 2012-09-04

    Why was the workaround removed?
    We now have the problem with PMD 5.0.0 under Eclipse with Java 1.5

     
  • Andreas Dangel

    Andreas Dangel - 2012-10-07

    See also [url]https://sourceforge.net/tracker/index.php?func=detail&aid=3565001&group_id=56262&atid=479921[/url]

     

Log in to post a comment.