g_signal_connect returns int while GLib returns gulong, so DropTarget handler ids break at 2^31
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Read the native declarations in bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java alongside the generated stubs in bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c. Then inspect the four handler fields and their connect/disconnect uses in bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java. Done means the producer declarations and retained handler IDs preserve the GLib return value; build and test the GTK SWT bindings.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
OS.g_signal_connect is declared to return a Java int. GLib's g_signal_connect is a macro over g_signal_connect_data, which returns gulong — 64-bit on LP64. The generated stub casts the result down with (jint), so the C compiler stays quiet and javac never sees the C declaration.
// bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java:1357
public static final native int g_signal_connect(long instance, byte[] detailed_signal, long proc, long data);
// OS.java:1402 — this side was widened by #462 / 417af5e1
public static final native void g_signal_handler_disconnect(long instance, long handler_id);
/* bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c */
rc = (jint)g_signal_connect((gpointer)arg0, (const gchar *)lparg1, ...);
// bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
:103 int drag_motion_handler;
:206 drag_motion_handler = OS.g_signal_connect(control.handle, OS.drag_motion, ...);
:669 OS.g_signal_handler_disconnect(control.handle, drag_motion_handler);
What it can cause
#462 widened g_signal_handler_disconnect, but the id is truncated by the producer before it ever reaches the consumer, and DropTarget holds it in an int field. Java's int → long widening is a sign extension (JLS 5.1.2), so widening the parameter could not recover the bits:
| handler id | what GLib receives on disconnect | effect |
|---|---|---|
< 2^31 |
the same id | fine — which is why this has not been seen |
2^31 … 2^32 |
0xFFFFFFFF80000000-style |
an id GLib never issued; the handler is not disconnected and keeps running against a disposed DropTarget |
> 2^32 |
a different, small id (2^32 + 5 → 5) |
may name a live handler belonging to something else |
The threshold usually quoted for this is 4G, because that is where a gulong stops fitting in 32 bits. Java's int is signed and the conversion back is a sign extension, so the first id that fails to round-trip is 2 147 483 648, half of that. Against the rate measured in 417af5e1 ("counter jumps by ~20k" per window open and close), that halves the time to failure.
No observed failure — nothing here was built or run, and no id above 2^31 was witnessed. LP64 only; under LLP64 gulong is 32-bit and none of this applies.
Fix
Declare long on the producer — g_signal_connect, and the same for g_signal_connect_closure (OS.java:1364) and g_signal_connect_closure_by_id (:1372), which have the identical mismatch but whose returns no caller currently keeps — and widen the four DropTarget fields at :103-106 with them. The consumer side is already correct.
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. The 2^31 threshold was then derived as arithmetic. Every line quoted above was re-read on master on 2026-08-16.
Edited 2026-08-16: shortened. The claim, the evidence and the line numbers are unchanged.
- Lingua principale
- Java
- Stelle
- 202
- Fork
- 206
- Merge medio
- 16h 56m
- PR unite (30g)
- 110
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipse-platform/eclipse.platform.swt
-
`SWT_AWT.initFrame` takes `(long, String)` in Java; the GTK native declares no `className` and the Cocoa native types it `const char *`Forse già presa @GreenFuze l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
eclipse-platform/eclipse.platform.swt#3665 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eclipse-platform/eclipse.platform.swt#3546 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
eclipse-platform/eclipse.platform.swt#3428 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
eclipse-platform/eclipse.platform.swt#3336 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
eclipse-platform/eclipse.platform.swt#3718 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di eclipse-platform/eclipse.platform.swt
Issue simili
-
agent:working documentation enhancement go:build lane:needs-decision
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Sanne/incus-spawn#1435 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue up-for-grabs
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
AnikethTS/ChangeRadar#22 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#1202 ·
I maintainer di solito rispondono entro 1 giorno
-
admin sql type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
library-new-request priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
oracle/graalvm-reachability-metadata#10911 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno