WebKitGTK: six natives are declared to return `long`, but the WebKitGTK functions they call return `void`

Đã đóng Phù hợp với người mới
#3,761 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

Một pull request liên quan đã được merge.

  • #3774 của @GreenFuze — đã merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, java
Lĩnh vực
backend, desktop

Hướng nghiên cứu

Đọc sáu khai báo trong WebKitGTK.java tại các dòng được liệt kê và so sánh chúng với các stub được tạo trong webkitgtk.c cùng các header WebKitGTK được nêu trong issue. Đổi các khai báo thành void và tạo lại các stub. Công việc hoàn tất khi cả sáu lệnh gọi được tạo khớp với kiểu trả về void của các hàm.

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

Mô tả

Six natives in WebKitGTK.java are declared to return long, but the WebKitGTK functions they call return void. The generated stubs call each one through a function pointer typed to return jlong, so the C compiler stays quiet.

// bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java:275, :381, :627, :653, :656, :659
public static final native long webkit_web_context_allow_tls_certificate_for_host(long webKitWebContext, long GTlsCertificate, byte[] constGCharHost);
public static final native long webkit_network_session_allow_tls_certificate_for_host(long session, long certificate, byte[] constGCharHost);
public static final native long webkit_user_content_manager_add_script(long manager, long script);
public static final native long webkit_find_controller_search_next(long findController);
public static final native long webkit_find_controller_search_previous(long findController);
public static final native long webkit_find_controller_search_finish(long findController);
// bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c:1266
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong))fp)(arg0);
// webkit/WebKitFindController.h:84-85 (WebKitGTK 4.1, 2.52.5); the other five are void as well in
// WebKitFindController.h, WebKitUserContentManager.h, WebKitWebContext.h and, in 6.0, WebKitNetworkSession.h
WEBKIT_API void
webkit_find_controller_search_finish       (WebKitFindController *find_controller);
What it can cause

The value each native returns is whatever is left in the return register. Every caller in WebKit.java discards it (:307, :2600-2605, :2873, :2941, :2954; search_next and search_previous go through a Consumer<Long> at :2930-2931), so nothing goes wrong today. This is a mismatch in the declarations, not an observed failure. It is worth closing because a future caller would read a meaningless value as a result.

Fix

Declare the six as void in WebKitGTK.java and regenerate the stubs; the file already has many native void webkit_* declarations. I am happy to open the PR.

How this was found

By a research tool that compares each call a generated stub makes against the C declaration of the function it calls. Nothing was built or executed; every file quoted is in this repository at R4_40, and unchanged on master.

Ngôn ngữ chính
Java
Star
202
Fork
206
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
115

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 eclipse-platform/eclipse.platform.swt

Tất cả issue của eclipse-platform/eclipse.platform.swt

Issue tương tự

Thêm issue về Java

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.