dlopen ignores RTLD_GLOBAL when reopening an RTLD_LOCAL library

Đang mở
#28,058 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, wasm
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
27.8k
Fork
3.6k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
179

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của emscripten-core/emscripten

Tất cả issue của emscripten-core/emscripten

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.