Skip to content

Codegen: a facade callback with () userdata (db.exec(sql, cb, (), null)) traps the compiler in llvm::DataLayout::getTypeSizeInBits (#1618's interim spelling) #1622

Closed

Description

@ehartford

Found by the ruling §66 example rewrite (build/release_uat_fixtures/sqlite3_main.w). #1618's interim spelling for an exec with no row callback — a no-op fn with a unit userdata — is not compilable: the compiler itself dies (rc 133, EXC_BREAKPOINT in llvm::DataLayout::getTypeSizeInBits(llvm::Type*) + 452) in with build/with run; with check says ok.

Repro (stage1 of c18fdfe; SDKROOT set):

use facades.sqlite3
use c_import("sqlite3.h", link: "sqlite3")

fn no_row_unit(c: &Unit, n: c_int, v: *mut *mut i8, k: *mut *mut i8) -> c_int: 0

fn main:
    var db = Database.open(":memory:").unwrap()
    print(db.exec("CREATE TABLE t(value INTEGER)", no_row_unit, (), null))

The same call with a struct userdata (type Ctx { tag: i32 }, Ctx { tag: 1 }) or an i32 userdata (0) compiles and runs, with a named fn or a closure (c, n, v, k) => 0 alike — the trigger is U = Unit in the rendered exec[U](…, callback: extern "C" fn(&U, …), ud: &U, …): &Unit/sizeof(Unit) reaches LLVM as a void type. Two defects: the marshalling of a zero-sized userdata, and a compiler abort with no diagnostic. #1618's None spelling removes the need for a unit userdata in this program, but &() through a generic extern callback remains a legal spelling that must not abort the compiler.

lldb: frame #0: with-stage1llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const + 452 (brk #0x1`), no With frames unwound.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions