Five dynamically-loaded GTK/GDK functions are called through a wrong function-pointer type
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
調査の方向性
Start with the declarations at GTK4.java:426, :432, and :444 and GDK.java:1139 and :1199, then compare them with the generated stubs in gtk4.c and os.c at the cited lines. The issue says to correct the Java native signatures to match GTK/GDK and regenerate; verify the generated signatures and run relevant SWT tests or build checks. Done when all five declarations and generated calls match the cited GTK/GDK headers.
索引モデルが issue の本文から書いたものです。
説明
Several GTK/GDK entry points are loaded at run time and called through a function-pointer type the stub declares itself. The cast tells the compiler what the signature is, so nothing is left to check against GTK's header — and five of them disagree with it.
Three read a return value from a function GTK declares void:
/* bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c:1127 — gtk_color_dialog_set_title */
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, char *))fp)(arg0, (char *)lparg1);
/* gtk/gtkcolordialog.h */ void gtk_color_dialog_set_title (GtkColorDialog *self, const char *title);
/* gtk/gtkfontdialog.h */ void gtk_font_dialog_set_modal (GtkFontDialog *self, gboolean modal);
/* gtk/gtkfontdialog.h */ void gtk_font_dialog_set_title (GtkFontDialog *self, const char *title);
Same shape at gtk4.c:1887 (gtk_font_dialog_set_modal) and gtk4.c:1909 (gtk_font_dialog_set_title).
Two more disagree about the parameters:
/* bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c:2494 */
rc = (jlong)((jlong (CALLING_CONVENTION*)(jint, jint))fp)(arg0, arg1);
/* gdk/gdktoplevellayout.h */ GdkToplevelLayout *gdk_toplevel_layout_new (void);
/* os.c:2514 */
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(GdkToplevel *, jint, jint, GdkToplevelLayout *))fp)((GdkToplevel *)arg0, arg1, arg2, (GdkToplevelLayout *)arg3);
/* gdk/gdktoplevel.h */ void gdk_toplevel_present (GdkToplevel *toplevel, GdkToplevelLayout *layout);
What it can cause
ColorDialog.java:143 and FontDialog.java:171-172 call the first three, so that path runs. Java discards the value, so nothing goes wrong today — but reading the return of a void function is undefined behaviour, and it stops being harmless the moment anything uses rc.
For the other two I could find only the native declarations in GDK.java and no caller, so I believe they are unreachable — please treat that as my reading rather than a claim. If gdk_toplevel_present were called, GDK would take its second argument, a jint here, and use it as a GdkToplevelLayout *.
No observed failure; nothing was built or run.
Fix
gtk_color_dialog_set_modal, the fourth member of the same family, is already right:
// GTK4.java:460
public static final native void gtk_color_dialog_set_modal(long self, boolean modal);
/* gtk4.c:1106 */ ((void (CALLING_CONVENTION*)(jlong, gboolean))fp)(arg0, (gboolean)arg1);
So the other three want the same change: long → void in GTK4.java at :426, :432 and :444, then regenerate. Both call sites already ignore the result.
The two GDK declarations need the arguments GDK actually takes:
// GDK.java:1139 and :1199, as they would read after the change
public static final native void gdk_toplevel_present(long toplevel, long layout);
public static final native long gdk_toplevel_layout_new();
How this was found
By a research tool that compares each Java native declaration against the C declaration of the function its generated stub actually calls — here the case where the stub declares that signature itself, so no compiler sees both ends. Every line above was re-read on master (3e3b24b4) and against the GTK 4.23.2 headers.
Edited 2026-08-21: shortened. The claim, the evidence and the line numbers are unchanged.
- 主要言語
- Java
- スター
- 202
- フォーク
- 206
- 平均マージ
- 14時間 7分
- マージ済み PR(30日)
- 103
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-platform/eclipse.platform.swt のほかの issue
-
`SWT_AWT.initFrame` takes `(long, String)` in Java; the GTK native declares no `className` and the Cocoa native types it `const char *`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
eclipse-platform/eclipse.platform.swt#3665 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
eclipse-platform/eclipse.platform.swt#3546 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
eclipse-platform/eclipse.platform.swt#3428 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
eclipse-platform/eclipse.platform.swt#3336 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
eclipse-platform/eclipse.platform.swt#3718 ·
メンテナーはふだん 1 日以内に返信
eclipse-platform/eclipse.platform.swt の issue をすべて見る
似ている issue
-
RRateLimiter acquire methods accept negative permits and raise available permits above the rate.オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
krahets/hello-algo#1993 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
NationalSecurityAgency/ghidra#9884 ·
メンテナーはふだん 2 日以内に返信
-
Status: Pending Review Type: Feature Request
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
OpenRefine/OpenRefine#8019 ·
メンテナーはふだん 1 日以内に返信
-
`timer` rule rejects dates the engine accepts対応中かも @MFA-G が今日担当しました。 オープンbug ready
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
camunda/bpmnlint-plugin-camunda-compat#281 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信