Uploaded image for project: 'Commons Daemon'
  1. Commons Daemon
  2. DAEMON-451

Prunsrv does not use configured stack size for the main thread in jvm mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3.3
    • 1.3.4
    • Procrun
    • None

    Description

      This issue was originally reported for Apache Tomcat, see
      https://bz.apache.org/bugzilla/show_bug.cgi?id=66327

      A user provided a sample web application (see BZ 66327 attachment 38426). This web application was deployed on Apache Tomcat 9.0.70 (uses Commons Daemon 1.3.3), configured as a Windows Service.

      The sample application performs a deep recursion at startup, that prints numbers from 1 up to 25000. In the default configuration it fails with a StackOverflowError.

      To reproduce:
      1. Build the sample web application:
      1.1. Download it from BZ 66327 (attachment 38426).
      1.2. Change its pom.xml file, removing "jersey-container-servlet" from dependencies. I do not know why it is there, it is not needed.
      1.3. Build it with Apache Maven (`mvn package`). The result is target/TestStack-1.0-SNAPSHOT.war

      2. Install Apache Tomcat 9 on Windows as a service:
      2.1. Download and run the "32-bit/64-bit Windows Service Installer" (*.exe) from
      https://tomcat.apache.org/download-90.cgi
      2.2. Run it. Use default options, but once installation finishes choose to do not start the service.

      3. Deploy the web appplication on Tomcat:
      3.1. Copy the war file into webapps directory of Tomcat.

      4. Go into the bin directory of Tomcat and run prunmgr (tomcat9w.exe).

      5. Start Tomcat service, from the first page of prunmgr dialog.

      6. See the files in the logs directory of Tomcat.

      • See the localhost.2022-{}-{}.log file for a StackOverflowError
      • See the tomcat9-stdout.2022--*.log file for recursion counter.

      If the web application starts successfully, there will be no StackOverflowError, and the counter will go up to 25000.

      If the web application fails to start, there will be a StackOverflowError, and the recursion counter will stop at some value, usually somewhere around 15000.

      7. Try to increase the stack size:
      7.1. Stop the service. Clear the files in the logs directory.
      7.2. In prunmgr dialog (page "Java") change "Thread stack size" to a higher value, e.g. 3072.
      7.3. Do not forget to press the "Apply" button.
      7.4. Start the service.

      Expected behaviour:
      It is expected that changing the "Thread stack size" value to a higher value would eventually allow the web application to start successfully.

      Actual behaviour:
      It makes no difference.

      If I reconfigure Tomcat to use a thread pool when starting web applications, instead of using the main thread, the behaviour changes to the expected one. E.g. if you add startStopThreads="3" to a Host element in its conf/server.xml file. See Configuration Reference here:
      https://tomcat.apache.org/tomcat-9.0-doc/config/host.html

      Note: procrun here runs in jvm mode. The configuration for Tomcat is as follows (see bin/service.bat file):

      --StartMode jvm
      --StopMode jvm
      --StartClass org.apache.catalina.startup.Bootstrap
      --StopClass org.apache.catalina.startup.Bootstrap
      --StartParams start
      --StopParams stop

      Attachments

        Activity

          People

            Unassigned Unassigned
            kkolinko Konstantin Kolinko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: