Bug 63767

Summary: install windows service, tomcat9 start crash.
Product: Tomcat 9 Reporter: 王化亮 <6900277>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 9.0.26   
Target Milestone: -----   
Hardware: PC   
OS: All   
Attachments: the picture for this bug.

Description 王化亮 2019-09-24 07:57:08 UTC
Created attachment 36797 [details]
the picture for this bug.

i test 9.0.24 and 9.0.26 in my machine. after install to service. start the service, it will crash.
but i can start the tomcat by startup.bat.

9.0.22 is worked well in the same machine.

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

windows 2012 standard x64.

there are no logs in tomcat\log folder.
[2019-09-24 15:34:51] [info]  [11636] Apache Commons Daemon procrun (1.2.1.0 64-bit) started.
[2019-09-24 15:34:51] [info]  [11636] Running Service 'Tomcat9'...
[2019-09-24 15:34:51] [info]  [17080] Starting service...

windows event log
Faulting application name: Tomcat9.exe, version: 1.2.1.0, time stamp: 0x5d6fdd78
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0000000000a60f28
Faulting process id: 0x2724
Faulting application start time: 0x01d572ab2621283f
Faulting application path: E:\apache-tomcat-9.0.26\bin\Tomcat9.exe
Faulting module path: unknown
Report Id: 6412b89b-de9e-11e9-9651-001b215cf05b
Faulting package full name: 
Faulting package-relative application ID: 


if i doesn't intall it to service. only run startup.bat. everything work well.

in this machine 9.0.22 work well for services start.
Comment 1 王化亮 2019-09-24 07:59:08 UTC
it is not all windows 2012 doesn't work. it is random, i can't find the root case.
Comment 2 Mark Thomas 2019-09-24 18:24:24 UTC
To investigate this we'll need the steps to reproduce this on a clean install of the latest Tomcat 9.0.x release.

That you see different behaviour on different Windows 2012 systems suggests there is some factor external to Tomcat that is involved.

Some things to try/investigate:
- ensure all machines are fully patched
- on servers where this fails does a clean install with no additional
  configuration fail?
- enable debug logging for Commons Daemon
Comment 3 王化亮 2019-09-25 02:52:44 UTC
1.i fresh install windows 2012 x64, use this image.
en_windows_server_2012_vl_x64_dvd_917758.iso

2.install jdk1.8_201, set java_home
3.download tomcat9.0.26, unzip to C:\apache-tomcat-9.0.26
4.run service.bat install
5.start tomcat9 service.

it is crashed.

the common daemon debug log is:
[2019-09-24 19:47:12] [debug] ( prunsrv.c:1754) [ 1012] Apache Commons Daemon procrun log initialized.
[2019-09-24 19:47:12] [info]  ( prunsrv.c:1758) [ 1012] Apache Commons Daemon procrun (1.2.1.0 64-bit) started.
[2019-09-24 19:47:12] [info]  ( prunsrv.c:1668) [ 1012] Running Service 'Tomcat9'...
[2019-09-24 19:47:12] [debug] ( prunsrv.c:1441) [ 1680] Inside ServiceMain...
[2019-09-24 19:47:12] [debug] ( prunsrv.c:904 ) [ 1680] reportServiceStatusE: dwCurrentState = 2, dwWin32ExitCode = 0, dwWaitHint = 3000, dwServiceSpecificExitCode = 0.
[2019-09-24 19:47:12] [info]  ( prunsrv.c:1196) [ 1680] Starting service...
[2019-09-24 19:47:12] [debug] ( javajni.c:216 ) [ 1680] Explicit RuntimeLib specified 'C:\Program Files\Java\jdk1.8.0_201\jre\bin\server\jvm.dll'

windows event log:
Faulting application name: Tomcat9.exe, version: 1.2.1.0, time stamp: 0x5d6fdd78
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0000000001310f28
Faulting process id: 0xb44
Faulting application start time: 0x01d5734b8850d80a
Faulting application path: C:\apache-tomcat-9.0.26\bin\Tomcat9.exe
Faulting module path: unknown
Report Id: c6048720-df3e-11e9-93ea-0050568abc2e
Faulting package full name: 
Faulting package-relative application ID:
Comment 4 Mark Thomas 2019-09-25 10:07:50 UTC
I have been able to re-create this. Here are a few more details for the record

en_windows_server_2012_vl_x64_dvd_917758.iso
 - via My Visual Studio
 - Standard install with GUI
 - UK locale
 - All other settings using defaults
 - Networking configured via DHCP

Oracle jdk1.8_201 Windows 64-bit
 - default installation options

Java_HOME set to:
 C:\Program Files\Java\jdk1.8.0_201

apache-tomcat-9.0.26-windows-x64.zip
 - extract to C:\

I'm currently running Windows update to see if the root cause is a missing update.
Comment 5 Mark Thomas 2019-09-25 10:37:01 UTC
Installed Windows Update Agent 7.8.9200.16924 - no change.

Installed 2019-09 Preview of Monthly Quality Rollup for Windows Server 2012 for x64-based Systems (KB4516069) - problem resolved.

This does indeed look like an issue with a missing update.

Generally, Commons Daemon (and Tomcat) work on the basis that they are supported if all current updates have been applied. On that basis this looks like an issue with the server. That said, I'd like to dig into why this is happening as there may be scope to work-around the missing update in the Commons Daemon code.
Comment 6 Mark Thomas 2019-09-25 11:22:49 UTC
Found it. A good demonstration of my lack of C coding skills. I failed to initialise a variable so it was non-NULL when I expected it to be NULL causing Commons Daemon to try and call a function that didn't exist. Hence the crash.

I have a fix which I have tested locally. I'll get the fix applied to Commons Daemon start the release process. Hopefully we'll be able to pick up the fix in the next round of Tomcat releases.
Comment 7 Mark Thomas 2019-09-25 11:30:54 UTC
Already reported against Commons Daemon as https://issues.apache.org/jira/browse/DAEMON-408
Comment 8 王化亮 2019-09-26 01:36:11 UTC
thank you very much!
Comment 9 Christopher Schultz 2019-09-26 20:47:55 UTC
(In reply to Mark Thomas from comment #6)
> Found it. A good demonstration of my lack of C coding skills. I failed to
> initialise a variable so it was non-NULL when I expected it to be NULL

This should be caught by the compiler, even if it's a non-fatal compiler error.

Can you confirm that the compiler didn't complain about it? Perhaps there are more compiler flags we can add to the build in order to convert a non-fatal error into a fatal one.
Comment 10 Mark Thomas 2019-09-30 08:47:11 UTC
The compiler didn't report it.

The compiler runs with the default -W3 flag. The relevant warning is not shown unless you run with -W4.

Switching to -W4 generates quite a few warnings. I'm currently reviewing them.
Comment 11 Mark Thomas 2019-10-04 08:33:43 UTC
Commons Daemon 1.2.2 has been released and the Tomcat buildhas been updated to use it.

Fixed in:
- master for 9.0.27 onwards
- 8.5.x for 8.5.47 onwards
- 7.0.x for 7.0.97 onwards