typesense docker image not working on latest WSL release

Aperta
#3,090 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker, linux

Direzione di ricerca

Start by reproducing docker run typesense/typesense on the reported WSL kernel and checking whether /proc/self/io exists. Read the brpc startup path described in the report, along with the inline Dockerfile and procio-shim.c workaround. Done means the Typesense image starts without a segmentation fault on the affected WSL versions, including the reported 30.1 and 31.1 images.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pre-triage

Bug Description

Using the latest WSL versions typesense docker image is not working anymore. i did not test default installation but i guess it would have the same problem.

WSL-Version: 3.0.1.0
Kernelversion: 6.18.40.1-1

Error is "Segmentation fault".

Reproduction Steps

On a windows machine using the latest WSL version run the image inside wsl

docker run typesense/typesense

Expected vs Actual

Expected behavior
typesense should start up

Actual behavior
Segmentation fault.

Environment

  • Typesense version: 31.1 and 30.1

Additional Context

i got claude opus 5.5 to fix this issue by building new container image and LD_PRELOAD a helper class. It describes the problem like this:

Cause: The issue is with the WSL kernel 6.18.40.1-microsoft-standard-WSL2. It was built without CONFIG_TASKSTATS, which means that the file /proc/self/io does not exist.

Typesense uses the brpc library internally, and brpc reads this file during program startup. When the file is missing, brpc tries to log an error before the logging system is initialized, causing it to crash.

That is why even --version resulted in an immediate segfault, with no output at all, across all versions from 27.1 through 30.1.

I confirmed this with a gdb backtrace.

dockerfile:

ARG TYPESENSE_VERSION=30.1

FROM ubuntu:22.04 AS shim
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
COPY procio-shim.c /src/
RUN gcc -O2 -shared -fPIC -o /src/procio-shim.so /src/procio-shim.c -ldl

FROM typesense/typesense:${TYPESENSE_VERSION}
COPY --from=shim /src/procio-shim.so /usr/local/lib/procio-shim.so
ENV LD_PRELOAD=/usr/local/lib/procio-shim.so

procio-shim.so

// WSL kernels built without CONFIG_TASKSTATS have no /proc/<pid>/io.
// brpc (used by typesense) reads it during static init and segfaults when it is missing.
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>

static const char FAKE_IO[] =
    "rchar: 0\nwchar: 0\nsyscr: 0\nsyscw: 0\n"
    "read_bytes: 0\nwrite_bytes: 0\ncancelled_write_bytes: 0\n";

static int is_proc_io(const char *path) {
    if (!path) return 0;
    if (strcmp(path, "/proc/self/io") == 0) return 1;
    size_t n = strlen(path);
    return strncmp(path, "/proc/", 6) == 0 && n > 3 && strcmp(path + n - 3, "/io") == 0;
}

static FILE *fake_io(const char *path, const char *mode) {
    FILE *real = NULL;
    FILE *(*real_fopen)(const char *, const char *) = dlsym(RTLD_NEXT, "fopen");
    if (real_fopen) real = real_fopen(path, mode);
    if (real) return real;
    return fmemopen((void *)FAKE_IO, sizeof(FAKE_IO) - 1, "r");
}

FILE *fopen(const char *path, const char *mode) {
    if (is_proc_io(path)) return fake_io(path, mode);
    FILE *(*real)(const char *, const char *) = dlsym(RTLD_NEXT, "fopen");
    return real(path, mode);
}

FILE *fopen64(const char *path, const char *mode) {
    if (is_proc_io(path)) return fake_io(path, mode);
    FILE *(*real)(const char *, const char *) = dlsym(RTLD_NEXT, "fopen64");
    return real(path, mode);
}
Lingua principale
C++
Stelle
27.1k
Fork
1k
Merge medio
4g 4h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di typesense/typesense

Tutte le issue di typesense/typesense

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.