tursodatabase / tursodatabase/libsql

undefined behivior (in terms of the C standard) in libsql-sqlite3/src/vectorfloat16.c

Open
#1,915 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

I am not sure if this is intentional or not but if it is intentional I would expect some sort of comment documenting why this is the chosen implementation.

so in line 74 IN https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/src/vectorfloat16.c#L74
there is a deference of an int pointer as float. In ansi C that's undefined behavior because it breaks strict aliasing.
The situation can be mostly remedied for c99+ by using a union instead of just a u32.

however I dont really have a clean solution for purely ansi C.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting line 74 of libsql-sqlite3/src/vectorfloat16.c and the surrounding implementation to confirm how the int pointer is interpreted as a float. Check the applicable C-standard and project compatibility requirements; done means the strict-aliasing behavior is resolved or its intentional rationale is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.