Crash when hovering menu item

24 views
Skip to first unread message

Mo_Al_

unread,
Jul 27, 2025, 4:08:03 PMJul 27
to fltk.general
Hello

This was reported in the fltk-rs repo:
https://github.com/fltk-rs/fltk-rs/issues/1671

But it seems reproducible in C++, although I couldn't reproduce it on my setup, which appears to require a multimonitor setup on Linux. So I wanted to see if any of the devs here can reproduce it.

Although the issue was closed by the dev reporting it, the backtrace seems to point to a null dereference in (Fl_Menu.cxx:1068):
  STARTUP:
    menuwindow& cw = *pp.p[pp.menu_number];
    const Fl_Menu_Item* m = pp.current_item;
    if (!m->activevisible()) { // pointing at inactive item
      cw.set_selected(-1);
      initial_item = 0; // turn off startup code
      continue;
    } This was reported against a relelase which depends on FLTK 1.4.4.
However, looking at the code through git lens, it appears to not have changed for nearly 27 years :)

It might be that some reentrant code is nullifying the `m` variable elsewhere in certain setups.
The backtrace from the issue:

#0  0x00005cd18cb40182 in Fl_Menu_Item::activevisible (this=0x0)
    at /path/to/fltk/src/../FL/Fl_Menu_Item.H:451
#1  0x00005cd18cb4370f in Fl_Menu_Item::pulldown
    (this=0x5cd19bc3a470, X=760, Y=260, W=400, H=35, initial_item=0x0, pbutton=0x5cd19bbbfbb0, title=0x0, menubar=1)
    at /path/to/fltk/src/Fl_Menu.cxx:1068
#2  0x00005cd18cb44dda in Fl_Menu_Bar::handle (this=0x5cd19bbbfbb0, event=1)
    at /path/to/fltk/src/Fl_Menu_Bar.cxx:52
#3  0x00005cd18cb16085 in Widget_Derived<Fl_Sys_Menu_Bar>::handle (this=0x5cd19bbbfbb0, event=1)
    at /path/to/include/cfl_widget.hpp:77
#4  0x00005cd18cb32d62 in send (o=0x5cd19bbbfbb0, event=1)
    at /path/to/fltk/src/Fl_Group.cxx:96
#5  0x00005cd18cb334b7 in Fl_Group::handle (this=0x5cd19bbe6ab0, event=1)
    at /path/to/fltk/src/Fl_Group.cxx:226
#6  0x00005cd18cb138ad in Widget_Derived<Fl_Pack>::handle (this=0x5cd19bbe6ab0, event=1)
    at /path/to/include/cfl_widget.hpp:77
#7  0x00005cd18cb32d62 in send (o=0x5cd19bbe6ab0, event=1)
    at /path/to/fltk/src/Fl_Group.cxx:96
#8  0x00005cd18cb334b7 in Fl_Group::handle (this=0x5cd19bbf0380, event=1)
    at /path/to/fltk/src/Fl_Group.cxx:226
#9  0x00005cd18cb6241e in Fl_Window::handle (this=0x5cd19bbf0380, ev=1)
    at /path/to/fltk/src/Fl_Window.cxx:606
#10 0x00005cd18cb11de3 in Widget_Derived<Fl_Double_Window>::handle (this=0x5cd19bbf0380, event=1)
    at /path/to/include/cfl_widget.hpp:77
#11 0x00005cd18cb1aedc in send_event (event=1, to=0x5cd19bbf0380, window=0x5cd19bbf0380)
    at /path/to/fltk/src/Fl.cxx:1274
#12 0x00005cd18cb1b0fd in Fl::handle_ (e=1, window=0x5cd19bbf0380)
    at /path/to/fltk/src/Fl.cxx:1415
#13 0x00005cd18cb1af87 in Fl::handle (e=1, window=0x5cd19bbf0380)
    at /path/to/fltk/src/Fl.cxx:1364
#14 0x00005cd18cb85466 in fl_handle (thisevent=...)
    at /path/to/fltk/src/Fl_x.cxx:2301
#15 0x00005cd18cb7f3c3 in do_queued_events ()
    at /path/to/fltk/src/Fl_x.cxx:117
#16 0x00005cd18cb7f79e in fd_callback ()
    at /path/to/fltk/src/Fl_x.cxx:311
#17 0x00005cd18cb7ebd1 in Fl_Unix_Screen_Driver::poll_or_select_with_delay (this=0x5cd19bbc12d0, time_to_wait=1e+20)
    at /path/to/fltk/src/drivers/Unix/Fl_Unix_Screen_Driver.cxx:79
#18 0x00005cd18cb7f485 in Fl_X11_Screen_Driver::poll_or_select_with_delay (this=0x5cd19bbc12d0, time_to_wait=1e+20)
    at /path/to/fltk/src/Fl_x.cxx:138
#19 0x00005cd18cc0f03c in Fl_Unix_System_Driver::wait (this=0x5cd19bba69d0, time_to_wait=1e+20)
    at /path/to/fltk/src/drivers/Unix/Fl_Unix_System_Driver.cxx:810
#20 0x00005cd18cb1a18d in Fl::wait (time_to_wait=1e+20)
    at /path/to/fltk/src/Fl.cxx:632
#21 0x00005cd18cb1a1ab in Fl::run ()
    at /path/to/fltk/src/Fl.cxx:652

The C++ repro:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Pack.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/Fl_Text_Display.H>
#include <cstdio>
#include <string>

#define APP_VERSION "0.1.0"

int main() {
  Fl::scheme("gtk+");
  Fl::visual(FL_MULTISAMPLE | FL_ALPHA);
  Fl_Double_Window wind(400, 600, (std::string("J1939 Log ") + APP_VERSION).c_str());
  Fl_Pack pack(0, 0, wind.w(), wind.h());
  pack.type(Fl_Pack::VERTICAL);
  Fl_Sys_Menu_Bar menu(0, 0, 100, 35);
  menu.add("&Menu/Crash...\t",
           0,
           [](Fl_Widget*, void*) { fprintf(stderr, "Boom\n"); },
           nullptr,
           0
  );

  Fl_Text_Display text(0, 0, 100, 100);
  pack.resizable(&text);
  pack.end();
  wind.end();
  wind.resizable(&wind);
  wind.show();
  return Fl::run();
}

Gonzalo Garramuño

unread,
Jul 27, 2025, 5:56:30 PMJul 27
to fltkg...@googlegroups.com

C++ program works fine for me with two monitors under both X11 and Wayland.

El 27/7/25 a las 17:08, Mo_Al_ escribió:
Hello

This was reported in the fltk-rs repo:
https://github.com/fltk-rs/fltk-rs/issues/1671

But it seems reproducible in C++, although I couldn't reproduce it on my setup, which appears to require a multimonitor setup on Linux. So I wanted to see if any of the devs here can reproduce it.

The C++ repro:
...etc..
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/bfa0491a-ec5d-48f4-bdd9-692bfbde6fd0n%40googlegroups.com.
-- 
ggar...@gmail.com

Manolo

unread,
Jul 28, 2025, 3:03:26 AMJul 28
to fltk.general
Neither do I get a crash here with the C++ repo program under Wayand and Ubuntu 25.04 with 2 displays.
Reply all
Reply to author
Forward
0 new messages