Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amd64 compiler bug #1111

Closed
ncruces opened this issue Feb 8, 2023 · 13 comments · Fixed by #1118
Closed

amd64 compiler bug #1111

ncruces opened this issue Feb 8, 2023 · 13 comments · Fixed by #1118
Assignees
Labels
bug Something isn't working

Comments

@ncruces
Copy link
Collaborator

ncruces commented Feb 8, 2023

Describe the bug

While developing github.com/ncruces/go-sqlite3 I found an issue where a unit test was breaking on my windows machine (but not on GitHub CI).

Basically, running the same code produces a different result on that computer, failing the test. I found that switching to the interpreter fixes the issue on that computer. On other platforms, on GitHub CI, and on a friend's Windows computer, I can't repro the bug. The bug is consistent (always the same output), and survived a computer reboot.

To Reproduce

On the affected computer:

git clone https://github.com/ncruces/wazero-sqlite3-bug.git
cd wazero-sqlite3-bug
go run ./cmd

Expected output:

[2023/02/08 00:00:00] compiled "2.500000", interpreted "2.500000", want "2.500000"

Actual output in affected computer:

[2023/02/08 00:00:00] compiled "100000000000000000.000000", interpreted "2.500000", want "2.500000"

Environment (please complete the relevant information):

  • go version go1.20 windows/amd64
  • go version go1.19.4 windows/amd64
  • wazero Version: v1.0.0-pre.8
  • Host architecture: amd64
  • Runtime mode: compiler
  • Windows: 10.0.19045.2546

Additional context

The repo above runs the test in a matrix of OS versions (all the ones available on GitHub), and can't trigger the issue.

The command that runs is not actually the failing unit test. It's just an attempt at a simpler case. The tests that fail are these two. Also float to text conversions gone bad. I've inspected the code that converts float to text in SQLite and nothing in particular comes up.

Not sure what to make of this…

@ncruces ncruces added the bug Something isn't working label Feb 8, 2023
@mathetake mathetake self-assigned this Feb 8, 2023
@mathetake
Copy link
Member

thanks @ncruces for always the detailed explanation of what's going on. This indeed sounds like a very weird bug. WIll look into it in a day or so (wish me luck so that I could reproduce locally with my windows machine 😄 )

@mathetake
Copy link
Member

Oh one thing I would like you @ncruces to do is to run unit tests of wazero locally on your machine experiencing the bug. That would be helpful if we could find the failing test case.

@mathetake
Copy link
Member

mathetake commented Feb 9, 2023

OK bad news is that I failed to reproduce on my windows machine 😞

PS C:\Users\takeshi\wazero-sqlite3-bug> go run .\cmd\    
2023/02/08 20:24:58 compiled "2.500000", interpreted "2.500000", want "2.500000"       

the following is the system info:

PS C:\Users\takeshi\wazero-sqlite3-bug> systeminfo

Host Name:                 DESKTOP-R7BP8OG
OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.19045 N/A Build 19045
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          takeshi
Registered Organization:
Product ID:                00326-10000-00000-AA923
Original Install Date:     1/30/2023, 3:28:15 AM
System Boot Time:          2/8/2023, 6:53:59 PM
System Manufacturer:       Apple Inc.
System Model:              MacBookPro14,1
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 142 Stepping 9 GenuineIntel ~2401 Mhz
BIOS Version:              Apple Inc. 429.140.8.0.0, 6/13/2021

@mathetake
Copy link
Member

mathetake commented Feb 9, 2023

one thing I can guess might be related is this issue #580

@mathetake
Copy link
Member

@ncruces could you run the following command in your Windows machine so that I can see what kind of variant your x86 processor is?

go run github.com/klauspost/cpuid/v2/cmd/cpuid@latest
PS C:\Users\takeshi\wazero-sqlite3-bug> go run github.com/klauspost/cpuid/v2/cmd/cpuid@latest
go: downloading github.com/klauspost/cpuid v1.3.1
go: downloading github.com/klauspost/cpuid/v2 v2.2.3
Name: Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Vendor String: GenuineIntel
Vendor ID: Intel
PhysicalCores: 2
Threads Per Core: 2
Logical Cores: 4
CPU Family 6 Model: 142 Stepping: 9
Features: ADX,AESNI,AVX,AVX2,BMI1,BMI2,CLMUL,CMOV,CMPXCHG8,CX16,ERMS,F16C,FLUSH_L1D,FMA3,FXSR,FXSROPT,HLE,HTT,IBPB,LAHF,LZCNT,MD_CLEAR,MMX,MOVBE,MPX,NX,OSXSAVE,POPCNT,RDRAND,RDSEED,RDTSCP,RTM,RTM_ALWAYS_ABORT,SGX,SPEC_CTRL_SSBD,SRBDS_CTRL,SSE,SSE2,SSE3,SSE4,SSE42,SSSE3,STIBP,SYSCALL,SYSEE,VMX,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT,XSAVES
Microarchitecture level: 3
Cacheline bytes: 64
L1 Instruction Cache: 32768 bytes
L1 Data Cache: 32768 bytes
L2 Cache: 262144 bytes
L3 Cache: 4194304 bytes
Frequency: 2500000000 Hz
Boost Frequency: 4000000000 Hz
SGX: {Available:true LaunchControl:false SGX1Supported:false SGX2Supported:false MaxEnclaveSizeNot64:1 MaxEnclaveSize64:1 EPCSections:[]}

@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

Wow, lots of leads to follow through. Great, thanks!

I'll start with the easy ones, cpuid:

Name: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Vendor String: GenuineIntel
Vendor ID: Intel
PhysicalCores: 2
Threads Per Core: 2
Logical Cores: 4
CPU Family 6 Model: 58 Stepping: 9
Features: AESNI,AVX,AVXSLOW,CLMUL,CMOV,CMPXCHG8,CX16,ERMS,F16C,FLUSH_L1D,FXSR,FXSROPT,HTT,HYPERVISOR,IA32_ARCH_CAP,IBPB,LAHF,MD_CLEAR,MMX,NX,OSXSAVE,POPCNT,RDRAND,RDTSCP,SPEC_CTRL_SSBD,SSE,SSE2,SSE3,SSE4,SSE42,SSSE3,STIBP,SYSCALL,SYSEE,X87,XSAVE,XSAVEOPT
Microarchitecture level: 2
Cacheline bytes: 64
L1 Instruction Cache: 32768 bytes
L1 Data Cache: 32768 bytes
L2 Cache: 262144 bytes
L3 Cache: 3145728 bytes
Frequency: 2500000000 Hz

And systeminfo (some details redacted):

Host Name:                 XXX
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19045 N/A Build 19045
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          xxx@xxx.com
Registered Organization:
Product ID:                00330-80000-00000-AA298
Original Install Date:     28/11/2020, 16:57:57
System Boot Time:          08/02/2023, 19:38:57
System Manufacturer:       ASUSTeK Computer INC.
System Model:              VC60
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 58 Stepping 9 GenuineIntel ~2501 Mhz
BIOS Version:              American Megatrends Inc. 0901, 17/04/2014
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              00002000
Time Zone:                 (UTC+00:00) Dublin, Edinburgh, Lisbon, London
Total Physical Memory:     12,196 MB
Available Physical Memory: 8,787 MB
Virtual Memory: Max Size:  14,052 MB
Virtual Memory: Available: 10,876 MB
Virtual Memory: In Use:    3,176 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              \\XXX
Hotfix(s):                 24 Hotfix(s) Installed.
                           [01]: KB5022405
                           [02]: KB4562830
                           [03]: KB4570334
                           [04]: KB4577266
                           [05]: KB4580325
                           [06]: KB4586864
                           [07]: KB4593175
                           [08]: KB4598481
                           [09]: KB5000736
                           [10]: KB5012170
                           [11]: KB5015684
                           [12]: KB5019275
                           [13]: KB5006753
                           [14]: KB5007273
                           [15]: KB5011352
                           [16]: KB5011651
                           [17]: KB5014032
                           [18]: KB5014035
                           [19]: KB5014671
                           [20]: KB5015895
                           [21]: KB5016705
                           [22]: KB5018506
                           [23]: KB5020372
                           [24]: KB5005699
Network Card(s):           3 NIC(s) Installed.
                           [01]: Realtek 8821AE Wireless LAN 802.11ac PCI-E NIC
                                 Connection Name: Wi-Fi
                                 Status:          Hardware not present
                           [02]: Realtek PCIe GbE Family Controller
                                 Connection Name: Ethernet
                                 DHCP Enabled:    Yes
                                 DHCP Server:     192.168.x.x
                                 IP address(es)
                                 [01]: 192.168.x.x
                                 [02]: xxxx::xxxx:xxxx:xxxx:xxxx
                                 [03]: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
                                 [04]: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
                           [03]: WireGuard Tunnel
                                 Connection Name: XXX
                                 DHCP Enabled:    No
                                 IP address(es)
                                 [01]: 192.168.x.x
                                 [02]: 192.168.x.x
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

You suspecting a CPU issue (which makes a lot more sense) got me thinking, can I run this on Linux on this machine? Bare metal is kinda hard, but I do have WSL installed, so I built the Linux binary and ran it on WSL, and: same issue.

So same Windows+Linux binaries are OK in other computers, and have the same consistent bug on this computer (on Windows+WSL).

More than likely this is indeed a CPU issue. I'll change the thread title to reflect that.

@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

CPU features above as a diff:

--- ncruces	2023-02-09 10:00:00
+++ mathetake	2023-02-09 10:00:00
@@ -1,37 +1,52 @@
+ADX
 AESNI
 AVX
-AVXSLOW
+AVX2
+BMI1
+BMI2
 CLMUL
 CMOV
 CMPXCHG8
 CX16
 ERMS
 F16C
 FLUSH_L1D
+FMA3
 FXSR
 FXSROPT
+HLE
 HTT
-HYPERVISOR
-IA32_ARCH_CAP
 IBPB
 LAHF
+LZCNT
 MD_CLEAR
 MMX
+MOVBE
+MPX
 NX
 OSXSAVE
 POPCNT
 RDRAND
+RDSEED
 RDTSCP
+RTM
+RTM_ALWAYS_ABORT
+SGX
 SPEC_CTRL_SSBD
+SRBDS_CTRL
 SSE
 SSE2
 SSE3
 SSE4
 SSE42
 SSSE3
 STIBP
 SYSCALL
 SYSEE
+VMX
 X87
+XGETBV1
 XSAVE
+XSAVEC
 XSAVEOPT
+XSAVES

@ncruces ncruces changed the title Windows compiler bug amd64 compiler bug Feb 9, 2023
@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

OK, so running:

git clone https://github.com/tetratelabs/wazero.git
cd wazero
make test

On Git bash, with GNU make installed:

ok      github.com/tetratelabs/wazero   4.921s
ok      github.com/tetratelabs/wazero/api       0.623s
?       github.com/tetratelabs/wazero/imports/go        [no test files]
ok      github.com/tetratelabs/wazero/cmd/wazero        45.325s
ok      github.com/tetratelabs/wazero/examples/allocation/rust  0.810s
ok      github.com/tetratelabs/wazero/examples/allocation/tinygo        1.234s
ok      github.com/tetratelabs/wazero/examples/allocation/zig   0.799s
ok      github.com/tetratelabs/wazero/examples/basic    0.722s
ok      github.com/tetratelabs/wazero/examples/cli      13.321s
ok      github.com/tetratelabs/wazero/examples/concurrent-instantiation 1.049s
ok      github.com/tetratelabs/wazero/examples/import-go        0.950s
ok      github.com/tetratelabs/wazero/examples/multiple-results 0.840s
ok      github.com/tetratelabs/wazero/examples/multiple-runtimes        0.951s
ok      github.com/tetratelabs/wazero/experimental      0.704s
ok      github.com/tetratelabs/wazero/experimental/logging      0.570s
ok      github.com/tetratelabs/wazero/imports/assemblyscript    0.571s
ok      github.com/tetratelabs/wazero/imports/assemblyscript/example    0.773s
ok      github.com/tetratelabs/wazero/imports/emscripten        0.567s
?       github.com/tetratelabs/wazero/internal/assemblyscript   [no test files]
ok      github.com/tetratelabs/wazero/imports/go/example        56.367s
--- FAIL: Test_pathReadlink (0.63s)
    require.go:312: expected no error, but was symlink top\top-original-file C:\Users\ncruc\AppData\Local\Temp\Test_pathReadlink1227449904\001/top/top-symlinked: A required privilege is not held by the client.
        C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3682
--- FAIL: Test_pathSymlink_errors (0.07s)
    --- FAIL: Test_pathSymlink_errors/success (0.00s)
        require.go:312: expected 0, but was 29: want ESUCCESS but got EIO
            C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/wasi_test.go:148
            C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3934
    --- FAIL: Test_pathSymlink_errors/errors (0.00s)
        --- FAIL: Test_pathSymlink_errors/errors/EEXIST (0.00s)
            require.go:312: expected 20, but was 29: want EEXIST but got EIO
                C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/wasi_test.go:148
                C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3970
FAIL
FAIL    github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1    16.779s
?       github.com/tetratelabs/wazero/internal/fstest   [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/custom      [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/goos        [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/goarch      [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/run [no test files]
?       github.com/tetratelabs/wazero/internal/ieee754  [no test files]
--- FAIL: Test_main (4.40s)
    --- FAIL: Test_main/zig (2.49s)
        require.go:312: expected "", but was "integer overflowexit_code: 1
            "
            C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/example/cat_test.go:26
--- FAIL: Test_cli (64.79s)
    --- FAIL: Test_cli/zig (6.60s)
        --- FAIL: Test_cli/zig//test.txt (6.60s)
            require.go:312: expected no error, but was exit status 1: integer overflowexit status 1

                C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/example/cat_test.go:98
FAIL
FAIL    github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/example    70.084s
ok      github.com/tetratelabs/wazero/internal/asm      0.890s
ok      github.com/tetratelabs/wazero/internal/asm/amd64        0.982s
ok      github.com/tetratelabs/wazero/internal/asm/arm64        4.483s
ok      github.com/tetratelabs/wazero/internal/assemblyscript/logging   0.812s
--- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt (0.02s)
    --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz (0.01s)
        --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32 (0.00s)
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000000000000000000 (0.00s)
                require.go:312: expected 32, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000000000000000001 (0.00s)
                require.go:312: expected 31, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000000000000010000 (0.00s)
                require.go:312: expected 27, but was 4
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000000000001000000 (0.00s)
                require.go:312: expected 25, but was 6
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/10000000000000000000000000000000 (0.00s)
                require.go:312: expected 0, but was 31
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000011111111110000 (0.00s)
                require.go:312: expected 18, but was 13
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000000000010101010 (0.00s)
                require.go:312: expected 24, but was 7
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/00000000000000000001111111111111 (0.00s)
                require.go:312: expected 19, but was 12
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i32/1111111111111111111111111111111111111111111111111111111111111111 (0.00s)
                require.go:312: expected 0, but was 31
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:835
        --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64 (0.00s)
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000000000000000000 (0.00s)
                require.go:312: expected 64, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000000000000000001 (0.00s)
                require.go:312: expected 63, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000000000000010000 (0.00s)
                require.go:312: expected 59, but was 4
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000000000001000000 (0.00s)
                require.go:312: expected 57, but was 6
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000010000000000000000000000000000000 (0.00s)
                require.go:312: expected 32, but was 31
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000011111111110000 (0.00s)
                require.go:312: expected 50, but was 13
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000000000010101010 (0.00s)
                require.go:312: expected 56, but was 7
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/0000000000000000000000000000000000000000000000000001111111111111 (0.00s)
                require.go:312: expected 51, but was 12
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Clz/i64/1111111111111111111111111111111111111111111111111111111111111111 (0.00s)
                require.go:312: expected 0, but was 63
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:837
    --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Ctz (0.00s)
        --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Ctz/i32 (0.00s)
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Ctz/i32/00000000000000000000000000000000 (0.00s)
                require.go:312: expected 32, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:841
        --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Ctz/i64 (0.00s)
            --- FAIL: TestCompiler_compile_Clz_Ctz_Popcnt/Ctz/i64/0000000000000000000000000000000000000000000000000000000000000000 (0.00s)
                require.go:312: expected 64, but was 0
                    C:/Users/ncruc/Desktop/wazero/internal/engine/compiler/compiler_numeric_test.go:843
FAIL
FAIL    github.com/tetratelabs/wazero/internal/engine/compiler  5.694s
ok      github.com/tetratelabs/wazero/internal/engine/interpreter       0.982s
ok      github.com/tetratelabs/wazero/internal/filecache        0.840s
ok      github.com/tetratelabs/wazero/internal/gojs     0.545s
ok      github.com/tetratelabs/wazero/internal/gojs/logging     1.053s
ok      github.com/tetratelabs/wazero/internal/gojs/util        0.770s
ok      github.com/tetratelabs/wazero/internal/gojs/values      0.879s
ok      github.com/tetratelabs/wazero/internal/integration_test/bench   0.920s
ok      github.com/tetratelabs/wazero/internal/integration_test/engine  0.925s
?       github.com/tetratelabs/wazero/internal/integration_test/vs      [no test files]
--- FAIL: TestSpecTestCompilerCache (16.04s)
    require.go:312: expected no error, but was exit status 1: --- FAIL: TestSpecTestCompilerCache (15.41s)
            --- FAIL: TestSpecTestCompilerCache/i32.wast (0.02s)
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:242 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:242 assert_return invoke clz ([{type: i32, value: 4294967295}])
                                have [31]
                                want [0]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:243 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:243 assert_return invoke clz ([{type: i32, value: 0}])
                                have [0]
                                want [32]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:244 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:244 assert_return invoke clz ([{type: i32, value: 32768}])
                                have [15]
                                want [16]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:245 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:245 assert_return invoke clz ([{type: i32, value: 255}])
                                have [7]
                                want [24]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:246 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:246 assert_return invoke clz ([{type: i32, value: 2147483648}])
                                have [31]
                                want [0]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:247 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:247 assert_return invoke clz ([{type: i32, value: 1}])
                                have [0]
                                want [31]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:248 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:248 assert_return invoke clz ([{type: i32, value: 2}])
                                have [1]
                                want [30]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:249 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:249 assert_return invoke clz ([{type: i32, value: 2147483647}])
                                have [30]
                                want [1]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i32.wast/assert_return/line:252 (0.00s)
                    require.go:312: expected true, but was false: i32.wast:252 assert_return invoke ctz ([{type: i32, value: 0}])
                                have [0]
                                want [32]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
            --- FAIL: TestSpecTestCompilerCache/i64.wast (0.03s)
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:242 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:242 assert_return invoke clz ([{type: i64, value: 18446744073709551615}])
                                have [63]
                                want [0]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:243 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:243 assert_return invoke clz ([{type: i64, value: 0}])
                                have [0]
                                want [64]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:244 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:244 assert_return invoke clz ([{type: i64, value: 32768}])
                                have [15]
                                want [48]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:245 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:245 assert_return invoke clz ([{type: i64, value: 255}])
                                have [7]
                                want [56]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:246 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:246 assert_return invoke clz ([{type: i64, value: 9223372036854775808}])
                                have [63]
                                want [0]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:247 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:247 assert_return invoke clz ([{type: i64, value: 1}])
                                have [0]
                                want [63]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:248 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:248 assert_return invoke clz ([{type: i64, value: 2}])
                                have [1]
                                want [62]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:249 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:249 assert_return invoke clz ([{type: i64, value: 9223372036854775807}])
                                have [62]
                                want [1]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
                --- FAIL: TestSpecTestCompilerCache/i64.wast/assert_return/line:252 (0.00s)
                    require.go:312: expected true, but was false: i64.wast:252 assert_return invoke ctz ([{type: i64, value: 0}])
                                have [0]
                                want [64]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
            --- FAIL: TestSpecTestCompilerCache/load.wast (0.01s)
                --- FAIL: TestSpecTestCompilerCache/load.wast/assert_return/line:201 (0.00s)
                    require.go:312: expected true, but was false: load.wast:201 assert_return invoke as-unary-operand ([])
                                have [0]
                                want [32]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
            --- FAIL: TestSpecTestCompilerCache/memory_grow.wast (0.09s)
                --- FAIL: TestSpecTestCompilerCache/memory_grow.wast/assert_return/line:299 (0.00s)
                    require.go:312: expected true, but was false: memory_grow.wast:299 assert_return invoke as-unary-operand ([])
                                have [0]
                                want [31]
                        C:/Users/ncruc/Desktop/wazero/internal/integration_test/spectest/spectest.go:439
        FAIL

        C:/Users/ncruc/Desktop/wazero/internal/integration_test/filecache/filecache_test.go:50
FAIL
FAIL    github.com/tetratelabs/wazero/internal/integration_test/filecache       17.837s
ok      github.com/tetratelabs/wazero/internal/integration_test/fs      0.794s
ok      github.com/tetratelabs/wazero/internal/integration_test/fuzzcases       9.035s
ok      github.com/tetratelabs/wazero/internal/integration_test/spectest        0.711s
ok      github.com/tetratelabs/wazero/internal/integration_test/vs/compiler     2.298s
ok      github.com/tetratelabs/wazero/internal/integration_test/vs/interpreter  12.228s
?       github.com/tetratelabs/wazero/internal/testing/dwarftestdata    [no test files]
?       github.com/tetratelabs/wazero/internal/testing/enginetest       [no test files]
ok      github.com/tetratelabs/wazero/internal/leb128   14.659s
ok      github.com/tetratelabs/wazero/internal/logging  0.729s
ok      github.com/tetratelabs/wazero/internal/moremath 0.932s
ok      github.com/tetratelabs/wazero/internal/platform 0.909s
ok      github.com/tetratelabs/wazero/internal/sys      0.878s
--- FAIL: TestDirFS_Readlink (0.02s)
    require.go:312: expected no error, but was symlink animals.txt C:\Users\ncruc\AppData\Local\Temp\TestDirFS_Readlink3161770538\001/symlinked-animals.txt: A required privilege is not held by the client.
        C:/Users/ncruc/Desktop/wazero/internal/sysfs/dirfs_test.go:581
--- FAIL: TestDirFS_Symlink (0.09s)
    require.go:312: expected errors.Is(A required privilege is not held by the client., file exists), but it wasn't
        C:/Users/ncruc/Desktop/wazero/internal/sysfs/dirfs_test.go:543
FAIL
FAIL    github.com/tetratelabs/wazero/internal/sysfs    1.200s
?       github.com/tetratelabs/wazero/internal/testing/hammer   [no test files]
?       github.com/tetratelabs/wazero/internal/testing/maintester       [no test files]
?       github.com/tetratelabs/wazero/internal/testing/proxy    [no test files]
ok      github.com/tetratelabs/wazero/internal/testing/fs       0.866s
?       github.com/tetratelabs/wazero/internal/version  [no test files]
ok      github.com/tetratelabs/wazero/internal/testing/require  0.764s
ok      github.com/tetratelabs/wazero/internal/u32      0.693s
ok      github.com/tetratelabs/wazero/internal/u64      0.823s
ok      github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1   0.825s
ok      github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1/logging   1.115s
ok      github.com/tetratelabs/wazero/internal/wasm     1.569s
ok      github.com/tetratelabs/wazero/internal/wasm/binary      0.867s
?       github.com/tetratelabs/wazero/internal/wasmruntime      [no test files]
ok      github.com/tetratelabs/wazero/internal/wasmdebug        2.055s
ok      github.com/tetratelabs/wazero/internal/wazeroir 0.474s
ok      github.com/tetratelabs/wazero/sys       0.421s
FAIL
make: *** [test] Error 1

Multiple failures, but the big one seems to be related to Clz_Ctz_Popcnt.

PS: The symlink one may affect others. This might have changed recently, but symlinks used to require admin privileges on Windows, so it's expected that they may fail.

@mathetake
Copy link
Member

@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

Yes, that fixes the issue. The only failing tests after it are symlink ones:

ok      github.com/tetratelabs/wazero   3.255s
ok      github.com/tetratelabs/wazero/api       (cached)
?       github.com/tetratelabs/wazero/imports/go        [no test files]
ok      github.com/tetratelabs/wazero/cmd/wazero        17.422s
ok      github.com/tetratelabs/wazero/examples/allocation/rust  0.679s
ok      github.com/tetratelabs/wazero/examples/allocation/tinygo        0.668s
ok      github.com/tetratelabs/wazero/examples/allocation/zig   0.601s
ok      github.com/tetratelabs/wazero/examples/basic    0.681s
ok      github.com/tetratelabs/wazero/examples/cli      (cached)
ok      github.com/tetratelabs/wazero/examples/concurrent-instantiation 0.685s
ok      github.com/tetratelabs/wazero/examples/import-go        0.666s
ok      github.com/tetratelabs/wazero/examples/multiple-results 0.663s
ok      github.com/tetratelabs/wazero/examples/multiple-runtimes        0.703s
ok      github.com/tetratelabs/wazero/experimental      0.626s
ok      github.com/tetratelabs/wazero/experimental/logging      0.302s
ok      github.com/tetratelabs/wazero/imports/assemblyscript    0.390s
ok      github.com/tetratelabs/wazero/imports/assemblyscript/example    0.570s
ok      github.com/tetratelabs/wazero/imports/emscripten        0.419s
?       github.com/tetratelabs/wazero/internal/assemblyscript   [no test files]
?       github.com/tetratelabs/wazero/internal/fstest   [no test files]
ok      github.com/tetratelabs/wazero/imports/go/example        19.205s
--- FAIL: Test_pathReadlink (0.02s)
    require.go:312: expected no error, but was symlink top\top-original-file C:\Users\ncruc\AppData\Local\Temp\Test_pathReadlink2953894191\001/top/top-symlinked: A required privilege is not held by the client.
        C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3682
--- FAIL: Test_pathSymlink_errors (0.03s)
    --- FAIL: Test_pathSymlink_errors/success (0.00s)
        require.go:312: expected 0, but was 29: want ESUCCESS but got EIO
            C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/wasi_test.go:148
            C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3934
    --- FAIL: Test_pathSymlink_errors/errors (0.00s)
        --- FAIL: Test_pathSymlink_errors/errors/EEXIST (0.00s)
            require.go:312: expected 20, but was 29: want EEXIST but got EIO
                C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/wasi_test.go:148
                C:/Users/ncruc/Desktop/wazero/imports/wasi_snapshot_preview1/fs_test.go:3970
FAIL
FAIL    github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1    5.817s
?       github.com/tetratelabs/wazero/internal/gojs/custom      [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/goarch      [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/goos        [no test files]
?       github.com/tetratelabs/wazero/internal/gojs/run [no test files]
?       github.com/tetratelabs/wazero/internal/ieee754  [no test files]
?       github.com/tetratelabs/wazero/internal/integration_test/vs      [no test files]
?       github.com/tetratelabs/wazero/internal/testing/dwarftestdata    [no test files]
?       github.com/tetratelabs/wazero/internal/testing/enginetest       [no test files]
?       github.com/tetratelabs/wazero/internal/testing/hammer   [no test files]
?       github.com/tetratelabs/wazero/internal/testing/maintester       [no test files]
?       github.com/tetratelabs/wazero/internal/testing/proxy    [no test files]
?       github.com/tetratelabs/wazero/internal/version  [no test files]
?       github.com/tetratelabs/wazero/internal/wasmruntime      [no test files]
ok      github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/example    52.943s
ok      github.com/tetratelabs/wazero/internal/asm      (cached)
ok      github.com/tetratelabs/wazero/internal/asm/amd64        (cached)
ok      github.com/tetratelabs/wazero/internal/asm/arm64        (cached)
ok      github.com/tetratelabs/wazero/internal/assemblyscript/logging   (cached)
ok      github.com/tetratelabs/wazero/internal/engine/compiler  5.717s
ok      github.com/tetratelabs/wazero/internal/engine/interpreter       (cached)
ok      github.com/tetratelabs/wazero/internal/filecache        (cached)
ok      github.com/tetratelabs/wazero/internal/gojs     0.501s
ok      github.com/tetratelabs/wazero/internal/gojs/logging     (cached)
ok      github.com/tetratelabs/wazero/internal/gojs/util        (cached)
ok      github.com/tetratelabs/wazero/internal/gojs/values      (cached)
ok      github.com/tetratelabs/wazero/internal/integration_test/bench   0.752s
ok      github.com/tetratelabs/wazero/internal/integration_test/engine  0.533s
ok      github.com/tetratelabs/wazero/internal/integration_test/filecache       35.649s
ok      github.com/tetratelabs/wazero/internal/integration_test/fs      0.903s
ok      github.com/tetratelabs/wazero/internal/integration_test/fuzzcases       7.662s
ok      github.com/tetratelabs/wazero/internal/integration_test/spectest        (cached)
ok      github.com/tetratelabs/wazero/internal/integration_test/vs/compiler     1.829s
ok      github.com/tetratelabs/wazero/internal/integration_test/vs/interpreter  11.517s
ok      github.com/tetratelabs/wazero/internal/leb128   (cached)
ok      github.com/tetratelabs/wazero/internal/logging  (cached)
ok      github.com/tetratelabs/wazero/internal/moremath (cached)
ok      github.com/tetratelabs/wazero/internal/platform (cached)
ok      github.com/tetratelabs/wazero/internal/sys      (cached)
--- FAIL: TestDirFS_Readlink (0.03s)
    require.go:312: expected no error, but was symlink animals.txt C:\Users\ncruc\AppData\Local\Temp\TestDirFS_Readlink2319260500\001/symlinked-animals.txt: A required privilege is not held by the client.
        C:/Users/ncruc/Desktop/wazero/internal/sysfs/dirfs_test.go:581
--- FAIL: TestDirFS_Symlink (0.22s)
    require.go:312: expected errors.Is(A required privilege is not held by the client., file exists), but it wasn't
        C:/Users/ncruc/Desktop/wazero/internal/sysfs/dirfs_test.go:543
FAIL
FAIL    github.com/tetratelabs/wazero/internal/sysfs    1.612s
ok      github.com/tetratelabs/wazero/internal/testing/fs       (cached)
ok      github.com/tetratelabs/wazero/internal/testing/require  (cached)
ok      github.com/tetratelabs/wazero/internal/u32      (cached)
ok      github.com/tetratelabs/wazero/internal/u64      (cached)
ok      github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1   (cached)
ok      github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1/logging   (cached)
ok      github.com/tetratelabs/wazero/internal/wasm     (cached)
ok      github.com/tetratelabs/wazero/internal/wasm/binary      (cached)
ok      github.com/tetratelabs/wazero/internal/wasmdebug        (cached)
ok      github.com/tetratelabs/wazero/internal/wazeroir (cached)
ok      github.com/tetratelabs/wazero/sys       (cached)
FAIL
make: *** [test] Error 1

And my use case works as well:

2023/02/09 12:00:00 compiled "2.500000", interpreted "2.500000", want "2.500000"

But singling out windows is maybe not the correct fix here? Since building and running on WSL still gives the old behaviour:

2023/02/09 12:00:00 compiled "100000000000000000.000000", interpreted "2.500000", want "2.500000"

My CPU is missing LZCNT, should that be tested at runtime?
I also think it's fair to simply disable the compiler in such cases, if that makes it easier.

@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

That condition seems flawed.
Replacing it with if true { and running it on my mac, make test passes, which suggests it's a CPU, not OS, issue.

@ncruces
Copy link
Collaborator Author

ncruces commented Feb 9, 2023

#1112 fixes this everywhere l could test. It introduces a dependency though. The fast, safe, no deps fix is to never use LZCNT. Long term, in house CPUID seems to be the way. And since it's AOT it doesn't suffer the runtime cost of CPUID.

@ncruces ncruces mentioned this issue Feb 9, 2023
@mathetake mathetake assigned evacchi and unassigned mathetake Feb 10, 2023
@ncruces
Copy link
Collaborator Author

ncruces commented Feb 10, 2023

I made another attempt on #1112 using a lighter dependency (just one function implemented in asm that, apparently, from the licence, originates within Go itself). With links to documentation for everything else.

Feel free to close (#1112) at your convenience (just trying to offer guidance) and ping me to test something (since I have the affected machine).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants