dlopen ignores RTLD_GLOBAL when reopening an RTLD_LOCAL library

Abierto
#28,058 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, wasm
Área
backend

Línea de trabajo

The report provides a minimal reproducer in test.c and commands to build and run it with Emscripten and Node. First trace how dlopen handles reopening a local library with RTLD_GLOBAL, then compare dlsym(RTLD_DEFAULT, "answer") with the reproducer’s expected result. Done means the global lookup returns 42 on both wasm32 and wasm64.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Reopening an RTLD_LOCAL library with RTLD_GLOBAL succeeds, but its symbols remain unavailable through RTLD_DEFAULT.
Reproduced with Emscripten 6.0.8 on both wasm32 and wasm64.

cat > test.c <<'EOF'
#ifdef BUILD_PROVIDER
int answer_value = 42;
int answer(void) { return answer_value; }
#else
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>

int main(void) {
  void *handle = dlopen("./provider.so", RTLD_NOW | RTLD_LOCAL);
  assert(handle);
  int (*answer_fn)(void) = dlsym(handle, "answer");
  assert(answer_fn && answer_fn() == 42);
  puts("Handle-specific lookup: 42");

  assert(dlopen("./provider.so", RTLD_NOW | RTLD_GLOBAL) == handle);
  dlerror();
  answer_fn = dlsym(RTLD_DEFAULT, "answer");
  if (!answer_fn) {
    printf("FAIL: %s\n", dlerror());
    return 1;
  }
  printf("Global lookup: %d\n", answer_fn());
  return 0;
}
#endif
EOF

Build the shared library:

emcc test.c -DBUILD_PROVIDER -shared -fPIC -m64 -fwasm-exceptions -O1 \
  -Wl,--export=answer -Wl,--export=answer_value -o provider.so

Build and run the main module:

emcc test.c -m64 -fwasm-exceptions -O1 \
  -sMAIN_MODULE=2 -sENVIRONMENT=node -sEXIT_RUNTIME=1 \
  --embed-file provider.so -o test.js

node test.js

Actual output (exit code 1):

Handle-specific lookup: 42
FAIL: Tried to lookup unknown symbol "answer" in dynamic lib: __main__

Expected: Global lookup: 42.

Replacing both -m64 flags with -m32 produces the same failure.

Lenguaje dominante
C++
Estrellas
27.8k
Forks
3.6k
Merge medio
1 d 3 h
PR fusionados (30 d)
179

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de emscripten-core/emscripten

Todos los issues de emscripten-core/emscripten

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.