tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.4k stars 909 forks source link

bug: net/http server not working on linux #4346

Open ldemailly opened 3 months ago

ldemailly commented 3 months ago
package main

import (
    "net/http"
    "log"
)

func helloHandler(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Hello, TinyGo!"))
}

func main() {
    mux := http.NewServeMux()
    mux.HandleFunc("/", helloHandler)
    log.Fatal(http.ListenAndServe(":8080", mux))
}
tinygo run .
panic: runtime error at 0x0000000000233e7f: nil pointer dereference
error: failed to run compiled binary /tmp/tinygo1722875622/main: signal: aborted (core dumped)
dkegel-fastly commented 3 months ago

This is, alas, documented not to work at https://tinygo.org/docs/reference/lang-support/stdlib/#nethttp

ldemailly commented 3 months ago

well there should be a way to isolate the crypto part no?

http is pretty basic

also... runtime error not build time?

dkegel-fastly commented 3 months ago

Yeah, that page needs some updating. If the problem is still crypto related, as I think dgryski mentioned, a stub of the offending crypto module might at least let plain old http work.