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

WASI input plugins do not work if compiled with latest version of tinygo #10026

Open
St1gven opened this issue Feb 28, 2025 · 1 comment · May be fixed by #10032
Open

WASI input plugins do not work if compiled with latest version of tinygo #10026

St1gven opened this issue Feb 28, 2025 · 1 comment · May be fixed by #10032

Comments

@St1gven
Copy link

St1gven commented Feb 28, 2025

Bug Report

Describe the bug
WASI input plugins do not work if compiled with latest version of tinygo

To Reproduce
tinygo 0.35.0, go 1.23.6, fluentbit 3.2.7 (Container image)

main.go file

package main

import "fmt"

func main() {
    fmt.Println("{\"test\":\"test\"}")
}

Build command:

tinygo build --target=wasi -o main.wasm main.go;

Fluent bit config:

[SERVICE]
    Flush        1
    Daemon       Off
    Log_Level    info
    HTTP_Server  Off
    HTTP_Listen  0.0.0.0
    HTTP_Port    2020

[INPUT]
    Name exec_wasi
    Tag  exec.wasi.local
    WASI_Path /config/input/main.wasm

[OUTPUT]
    Name  stdout
    Match *

After running fluentbit I get this error

WASI main function is not found

Expected behavior
See this message in fluentbit logs

[0] exec.wasi.local: [[1740722019.675380600, {}], {"wasi_stdout"=>"{"test": "test""}]

Screenshots
Image

Your Environment

  • Version used: fluentbit 3.2.7 (Container image)
  • Configuration: config file specified above
  • Environment name and version (e.g. Kubernetes? What version?): podman 5.3.2
  • Server type and version: linux 6.13.4-200.fc41.x86_64
  • Operating System and version: Fedora 41
  • Filters and plugins: exec_wasi input plugin

Additional context
With tinygo 0.24.0 and go 1.19.13 it works perfectly, but it's quite outdated and I would like to use the latest toolset.

@St1gven
Copy link
Author

St1gven commented Mar 2, 2025

It seems the problem is here https://github.com/fluent/fluent-bit/blob/master/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.c#L2579

WASM interpreter throws "wasi proc exit" exception on successful process execution, and it should be handled by the upper layer https://github.com/fluent/fluent-bit/blob/master/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c#L1110

Is it possible to use wasm_application_execute_main instead of wasm_runtime_call_wasm where all this handling is already done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant