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

Fix race in tinygo test #3934

Merged
merged 2 commits into from
Oct 4, 2023
Merged

Fix race in tinygo test #3934

merged 2 commits into from
Oct 4, 2023

Commits on Oct 4, 2023

  1. all: refactor goenv.Version to add the git sha1 if needed

    Previously all (except one!) usage of goenv.Version manually added the
    git sha1 hash, leading to duplicate code. I've moved this to do it all
    in one place, to avoid this duplication.
    aykevl committed Oct 4, 2023
    Configuration menu
    Copy the full SHA
    8e103a9 View commit details
    Browse the repository at this point in the history
  2. build: avoid sharing GlobalValues between build instances

    This happens with `tinygo test` for example when testing multiple
    packages at the same time. I found this because the compiler crashed in
    `make tinygo-test-fast`:
    
        fatal error: concurrent map writes
        fatal error: concurrent map read and map write
    
        goroutine 15 [running]:
        github.com/tinygo-org/tinygo/builder.Build({0x40002d0be0, 0xa}, {0x0, 0x0}, {0x4000398048, 0x14}, 0x40003b0000)
                /home/ayke/src/tinygo/tinygo/builder/build.go:131 +0x388
        main.buildAndRun({0x40002d0be0, 0xa}, 0x40003b0000, {0x8bc178, 0x40003a4090}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...)
                /home/ayke/src/tinygo/tinygo/main.go:856 +0x45c
        main.Test({0x40002d0be0, 0xa}, {0x8bc118, 0x40000b3a08}, {0x0?, 0x0?}, 0x40001e6000, {0x0, 0x0})
                /home/ayke/src/tinygo/tinygo/main.go:270 +0x758
        main.main.func3()
                /home/ayke/src/tinygo/tinygo/main.go:1718 +0xe4
        created by main.main in goroutine 1
                /home/ayke/src/tinygo/tinygo/main.go:1712 +0x34ec
    
    My solution is essentially to copy the map over instead of modifying it
    directly.
    
    I've also moved the code up a little, because I think that's a more
    sensible place (out of the way of the whole package compile logic).
    aykevl committed Oct 4, 2023
    Configuration menu
    Copy the full SHA
    b544a5b View commit details
    Browse the repository at this point in the history