FLTK logo

Re: [fltk.coredev] Rare crash on repeat_timeout on macOS

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Rare crash on repeat_timeout on macOS Manolo Dec 08, 2021  
 

Le mardi 7 décembre 2021 à 22:29:20 UTC+1, ggar...@gmail.com a écrit :


> El 7 dic. 2021, a las 13:33, Manolo <manol...@gmail.com> escribió:
>
> I would sggest you run your program under a debugger and make sure the pointer you transmit
> as 3rg argument to Fl::repeat_timeout() remains valid until the moment when the timeout runs.
>

I debugged the program with printfs and found out that the dangling pointer is not the one as parameter to repeat_timeout (which is "this" of the class), but the current_timer->timer one. It seems there’s a running issue with the list of mac_timers and their timing to be ready to be called on repeat_timeout, leading them to be not initialized. I am unsure of this Fl_Cocoa_Screen_Driver.cxx code as it seems to be running on one thread but do things that several threads would do.


void Fl_Cocoa_Screen_Driver::repeat_timeout(double time, Fl_Timeout_Handler cb, void* data)
{
if (!current_timer) {
add_timeout(time, cb, data);
return;
}

//////////////////////// ADDED and fixes my crashes, but I consider this a hack and not a true solution.
if ( current_timer->timer == nullptr ) {
return;
}
 
That you get  current_timer->timer == nullptr most probably means that delete_timer()
has been called before repeat_timeout() was called.
This means that the control did not stay continuously inside your callback function,
but was returned to cocoa at some point by your callback, in contradiction to what is required to use repeat_timeout().

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/d05a4686-fb12-4561-a787-9c0021ee4a2cn%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.