MantisBT - NetSurf
View Issue Details
0002228NetSurf[All Projects] Generalpublic2014-11-23 20:012016-04-12 11:50
ReporterChris Young 
Assigned To 
PlatformAmigaOSAmigaOSOS Version4.1
Product Version3.3 
Target Version3.6Fixed in Version 
Fixed in CI build #
Reported in CI build #2383
URL of problem page
Summary0002228: Possible race condition with scheduler
DescriptionWhen NetSurf deletes a scheduled event, there is the possibility that it is already "in transit" to be triggered before the delete takes effect.

This will occur in the following circumstance:
* The triggered event is sent to the main NetSurf loop using an external (eg. OS) timer, which includes details of the callback.
* The event is deleted before NetSurf returns to the main loop to pick up messages from the timer.
* The callback is then called but the pointer passed may no longer be valid = crash.
Steps To ReproduceI can reproduce this on recent AmigaOS builds as the callback is now passed back to NetSurf rather than NetSurf picking the events off the list itself. I've only seen problems with nsgif_animate.
Additional InformationI'm not sure much can be done about this except to mitigate any problems (or insist events are always picked off a shared list). I've attached a possible fix for nsgif_animate but it may not be a full solution if the content object itself has been freed too.
This also ties into bug#2227, as if nsgif_animate stops running long before the object is destroyed this issue would not have arisen.
TagsNo tags attached.
related to 0002227closed Chris Young nsgif_animate runs when gif not displayed 
Attached Filesdiff gif.diff (555) 2014-11-23 20:01

Chris Young   
2014-12-12 17:17   
There's a better fix in branch chris/stop-gif-anim which ensures if nsgif_animate gets called when it shouldn't, it won't continue to repeat (the animation callback now stops when there are no more users).
Branch will need checking/merging.

Issue History
2014-11-23 20:01Chris YoungNew Issue
2014-11-23 20:01Chris YoungFile Added: gif.diff
2014-11-23 20:01Chris YoungAdditional Information Updatedbug_revision_view_page.php?rev_id=1353#r1353
2014-12-01 14:15Vincent SandersStatusnew => acknowledged
2014-12-01 14:15Vincent SandersDescription Updatedbug_revision_view_page.php?rev_id=1363#r1363
2014-12-01 14:15Vincent SandersAdditional Information Updatedbug_revision_view_page.php?rev_id=1364#r1364
2014-12-09 15:21Chris YoungRelationship addedrelated to 0002227
2014-12-09 15:24Chris YoungSeverityminor => crash
2014-12-09 15:24Chris YoungTarget Version => 3.3
2014-12-12 17:17Chris YoungNote Added: 0000557
2015-02-28 16:03Vincent SandersTarget Version3.3 => 3.4
2016-02-16 13:46Vincent SandersTarget Version3.4 => 3.5
2016-04-12 11:50Vincent SandersTarget Version3.5 => 3.6