[Bug 38272] binaries produced by Go compiler hang when using time.Sleep() and time.Now() is not updated

wine-bugs at winehq.org wine-bugs at winehq.org
Mon Mar 23 13:40:08 CDT 2015


https://bugs.winehq.org/show_bug.cgi?id=38272

--- Comment #3 from Nikolay Sivov <bunglehead at gmail.com> ---
I looked it up out of curiosity, and the reason seems to be that Go runtime
doesn't use APIs to get timestamps, and instead uses fixed address access to
read process memory, where supposedly kernel mirrors some time info as well
other information:

--- src/runtime/os_windows.c ---
#pragma dataflag NOPTR
const KSYSTEM_TIME* INTERRUPT_TIME    = (KSYSTEM_TIME*)0x7ffe0008;
#pragma dataflag NOPTR
const KSYSTEM_TIME* SYSTEM_TIME        = (KSYSTEM_TIME*)0x7ffe0014;

static void badsystime(void);

#pragma textflag NOSPLIT
int64
runtimeВ·systime(KSYSTEM_TIME *timeaddr)
{
    KSYSTEM_TIME t;
    int32 i;
    void (*fn)(void);

    for(i = 1; i < 10000; i++) {
        // these fields must be read in that order (see URL above)
        t.High1Time = timeaddr->High1Time;
        t.LowPart = timeaddr->LowPart;
        t.High2Time = timeaddr->High2Time;
        if(t.High1Time == t.High2Time)
            return (int64)t.High1Time<<32 | t.LowPart;
        if((i%100) == 0)
            runtimeВ·osyield();
    }
    fn = badsystime;
    runtimeВ·onM(&fn);
    return 0;
}

#pragma textflag NOSPLIT
int64
runtimeВ·unixnano(void)
{
    return (runtimeВ·systime(SYSTEM_TIME) - 116444736000000000LL) * 100LL;
}
---

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.


More information about the wine-bugs mailing list