Skip to content

wasm error: out of bounds memory access #3836

Closed

Description

@ptman

Version

1.28.0

What happened?

sqlc generate crashes. It did work using sqlc 1.27.0

Relevant log output

$ sqlc generate
panic: start function[17] failed: wasm error: out of bounds memory access
        wasm stack trace:
                .$17()

goroutine 15 [running]:
github.com/wasilibs/go-pgquery/parser.newABI()
        $HOME/go/pkg/mod/github.com/wasilibs/[email protected]/parser/parser_wazero.go:161 +0x15b0      
github.com/wasilibs/go-pgquery/parser.getABI()
        $HOME/go/pkg/mod/github.com/wasilibs/[email protected]/parser/parser_wazero.go:203 +0x14a      
github.com/wasilibs/go-pgquery/parser.ParseToProtobuf({0xc000524800, 0x4345})
        $HOME/go/pkg/mod/github.com/wasilibs/[email protected]/parser/parser_wazero.go:62 +0x52      
github.com/wasilibs/go-pgquery.Parse({0xc000524800?, 0xc00054c000?})
        $HOME/go/pkg/mod/github.com/wasilibs/[email protected]/pg_query.go:27 +0x18      
github.com/sqlc-dev/sqlc/internal/engine/postgresql.(*Parser).Parse(0x0?, {0x1d9eb00?, 0xc0005a0fa0?})
        $HOME/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/engine/postgresql/parse.go:154 +0x57      
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseCatalog(0xc000622a08, {0xc00008f7e0?, 0xc000602060?, 0xa?})
        $HOME/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/compile.go:42 +0x238      
github.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseCatalog(...)
        $HOME/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/compiler/engine.go:68      
github.com/sqlc-dev/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {{0x0, 0x0}, {0xc000602060, 0xa}, ...}, ...)
        $HOME/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/cmd/generate.go:308 +0x198      
github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
        $HOME/go/pkg/mod/github.com/sqlc-dev/[email protected]/internal/cmd/process.go:107 +0x81a      
golang.org/x/sync/errgroup.(*Group).Go.func1()
        $HOME/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x50      
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        $HOME/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x93    

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Activity

  1. BalteMD commented on Feb 14, 2025

    @BalteMD

    Have you found a solution yet?

  2. luyendx commented on Feb 14, 2025

    @luyendx

    i have same issue with go1.24.0 windows/amd64
    i did work with sqlc 1.27.0

  3. karaMuha commented on Feb 14, 2025

    @karaMuha

    I have the same issue with go 1.24.0 linux/amd64

  4. kyleconroy commented on Feb 15, 2025

    @kyleconroy
    Collaborator

    Hey everyone, thanks for helping track down this issue. I think this may be an upstream issue (wasilibs/go-pgquery#34). In the meantime, can you please post a bit more information about your error?

    • Are you using the precompiled binaries or are you building it from source?
    • If building from source, what version of Go are you using?
    • If you're using Go 1.24, does using Go 1.23 make it work?
  5. pinned this issue on Feb 15, 2025
  6. kyleconroy commented on Feb 15, 2025

    @kyleconroy
    Collaborator

    Confirmed this is an upstream issue, tracking here wazero/wazero#2375

  7. ptman commented on Feb 24, 2025

    @ptman
    Author

    Now that it's fixed, and a new version of wazero has been released, sqlc needs to upgrade the deps for go 1.24 compat. There seems to be a problem with pg_query_go/v5 vs. pg_query_go/v6.

  8. Waldenesque commented on Feb 25, 2025

    @Waldenesque

    Don't know if this is worth noting or not...

    wazero/wazero#2382

    Might still be another patch bump to wazero coming before long?

  9. danielalexis commented on Mar 7, 2025

    @danielalexis

    No update yet. Works on one machine but not another

  10. Dzejk0p commented on Mar 18, 2025

    @Dzejk0p

    Has anyone found a solution/workaround yet?

  11. svenwltr commented on Mar 18, 2025

    @svenwltr

    Has anyone found a solution/workaround yet?

    It seems the fix was already merged in github.com/tetratelabs/wazero, but there were no relases yet. I was able to hotfix the issue by explicitly using the latest commit with go get github.com/tetratelabs/wazero@26d5f5eb4bd0a0b302927f84776312c58c41afb6.

  12. danielalexis commented on Mar 18, 2025

    @danielalexis
  13. nixoncode commented on Mar 18, 2025

    @nixoncode

    I really didn't want to downgrade go, I switched to wsl on windows and ran the sqlc generate command and it worked.

    is it only isolated to Windows?

  14. Cesar-Castill0 commented on Mar 19, 2025

    @Cesar-Castill0

    Using Go 1.23 and SQLC 1.27 in WSL works for me. Alternatively, you could use a Go version manager (like gvm) to run SQLC on Go 1.27 or below, while keeping your main project on Go 1.24.

  15. nixoncode commented on Mar 19, 2025

    @nixoncode

    Using Go 1.23 and SQLC 1.27 in WSL works for me. Alternatively, you could use a Go version manager (like gvm) to run SQLC on Go 1.27 or below, while keeping your main project on Go 1.24.

    I'm on 1.24/1.28 myself. I managed to run it successfully on WSL, Windows still throws the error, I was just suggesting that it might be a windows only issue.

    Thanks for the gvm suggestion, never heard of it but it sounds cool.

  16. Cesar-Castill0 commented on Mar 20, 2025

    @Cesar-Castill0

    Using Go 1.23 and SQLC 1.27 in WSL works for me. Alternatively, you could use a Go version manager (like gvm) to run SQLC on Go 1.27 or below, while keeping your main project on Go 1.24.

    I'm on 1.24/1.28 myself. I managed to run it successfully on WSL, Windows still throws the error, I was just suggesting that it might be a windows only issue.

    Thanks for the gvm suggestion, never heard of it but it sounds cool.

    I hear you , I was actually responding to Dzejk0p that WSL also works for me. In my testing I only got the issue with go 1.24* on windows with several sqlc versions, tried it on a Linux mint machine (go 1.24*) with no issues, definitely possible that the issue is windows specific. And Yeah I recently learned of it myself haha

  17. danielalexis commented on Mar 20, 2025

    @danielalexis

    go 1.28
    i think you meant SQLC 1.28

  18. Cesar-Castill0 commented on Mar 21, 2025

    @Cesar-Castill0

    go 1.28
    i think you meant SQLC 1.28

    Corrected, thanks

  19. kyleconroy commented on Mar 26, 2025

    @kyleconroy
    Collaborator

    A fix has been merged into main. Release should be going out next week. Please test the fix on main to make sure it's working for you.

  20. Nick-Anderssohn commented on Mar 27, 2025

    @Nick-Anderssohn

    A fix has been merged into main. Release should be going out next week. Please test the fix on main to make sure it's working for you.

    Just tried main; it fixed the issue for me.

  21. kyleconroy commented on Apr 16, 2025

    @kyleconroy
    Collaborator

    Alright, sadly the release workflow is borked right now due to some Apple code signing issues. I'm going to be traveling, so I'm not sure a release will happen in the next 10 days. I could tag a new release and not provide binaries, but that would cause more confusion.

    In the meantime, please install from main which fixes this issue.

    $ go install github.com/sqlc-dev/sqlc/cmd/sqlc@main
    
  22. kyleconroy commented on Apr 17, 2025

    @kyleconroy
    Collaborator

    Okay, got 1.29.0 out with this fix :)

  23. unpinned this issue on Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions