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

Inconsistent behavior of sin() math function on x86 (musl / alpine) #1241

Open
mil opened this issue May 10, 2024 · 0 comments
Open

Inconsistent behavior of sin() math function on x86 (musl / alpine) #1241

mil opened this issue May 10, 2024 · 0 comments

Comments

@mil
Copy link

mil commented May 10, 2024

It seems there is a bug where on x86 (tested on musl/alpine 3.19) I'm getting incorrect values for the sin() function.

Given a sample program which just runs select sin(8.9):

Results on x86 (incorrect):

-2.1634211956023357

Result on x86_64 (correct):

0.5010208564578846

Running within the sqlite3 CLI the same select sin(8.9) on x86 returns the correct 0.5010208564578846; so I believe this is a bug in go-sqlite3 or a binding. I'm not sure if this just effects alpine/musl x86 or additionally glibc x86.


Sample test program:

// Run via go run -tags=sqlite_math_functions foo.go
package main

import (
	"database/sql"
	"fmt"
	"log"
	_ "github.com/mattn/go-sqlite3"
)

func main() {
	db, err := sql.Open("sqlite3", ":memory:")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()
	rows, err := db.Query("select sin(8.9)")
	if err != nil {
		log.Fatal(err)
	}
	defer rows.Close()
	var result float64
	for rows.Next() {
		if err := rows.Scan(&result); err != nil {
			log.Fatal(err)
		}
	}
	fmt.Println("Result:", result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant