Fun experiences using Wine in Docker (part 2)
Posted on Thu 14 April 2016 in blog
After the last post about running Wine in Docker, it was time to try and actually use the image to perform a build.
The first time I tried, the build crashed due to some sort of exception. It turns out the following sequence of events was to blame:
- NMAKE, running under- wine, loads- msvcrt80.dll
- During its DllMain, this DLL calls_wfindfirst64i32(), passing it the path toMicrosoft.VC80.CRT.mainfest
- Internally, _wfindfirst64i32will:- Call FindFirstFileWwhich returns aWIN32_FIND_DATAWstructure, which includes aFILETIMEmember for each of creation, last access, and last write times.
- Pass each of those timestamps to a function that:- Calls FileTimeToLocalFileTimeto convert it to local time
- Calls FileTimeToSystemTimeto convert it to aSYSTEMTIMEstructure
- Passes each member of the SYSTEMTIMEstructure as arguments to another function, which raises anINVALID_PARAMETERexception (0xC000000D) if theYearargument is not between 1970 and 3000, inclusive
 
- Calls 
 
- Call 
When Docker, using its union filesystem, starts the container, the file access
times are zero, which is midnight, 1970-01-01. When this date is converted to
local time (in EST timezone, which is UTC-5), the timestamp is five hours
before midnight, 1970-01-01, which puts the year at 1969. This caused an
exception to be raised whenever NMAKE would run.
The solution was quite simple: Removing /etc/localtime made the system use
UTC time, which avoids the problem.
When I find my notes, I will explain how I leveraged WINE's debugging facilities to track down this very elusive problem.