https://bz.apache.org/bugzilla/show_bug.cgi?id=66327
--- Comment #11 from Konstantin Kolinko <knst.koli...@gmail.com> --- FYI. Retesting with latest Java, released in late October, the results are: 1. Java version does not matter. The StackOverflowError is reproducible with OP's Sample application using Apache Tomcat 9.0.70 using 64-bit - Java 8u352 (server jvm), - Java 11.0.17 (server jvm, client jvm) from Eclipse Adoptium on Windows 10. 2. Thread matters. 2.1. Note that in the Sample application the recursive call is triggered from contextInitialized(..) method of a ServletContextListener. With the default configuration of Tomcat 9.0.70 the code runs on the "main" thread. The thread name can be seen in the localhost.2022-**-**.log file, where the StackOverflowError is logged. > 06-Dec-2022 **:**:**.*** SEVERE [main] > org.apache.catalina.core.StandardContext.listenerStart Exception sending > context initialized event to listener instance of class > [stacktest.application.ApplicationServlet] > java.lang.StackOverflowError > ... 2.2. If I change Tomcat configuration to use a separate pool of threads to start web applications, the web application starts successfully. It prints numbers up to 25000, as expected. The configuration is done by adding startStopThreads attribute to a Host, for example: <Host ... startStopThreads="3"> For further reference, see https://tomcat.apache.org/tomcat-9.0-doc/config/host.html#Common_Attributes This is the workaround that I recommend for this issue. 2.3. Whether the stack size of the main thread can be configured, is a question for the Commons Daemon project. https://commons.apache.org/proper/commons-daemon/procrun.html There is no Apache Tomcat bug here. 3. As a side note. java.lang.Thread has a constructor that allows to specify the stackSize. > public Thread(ThreadGroup group, > Runnable target, > String name, > long stackSize) > @since 1.4 It may be that it will be useful to somebody. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org