kicad/include
Jon Evans 1e33928b96 Fix issues with zone filling connectivity locking
Two issues found with the locking system used to prevent access to
stale connectivity data during the zone fill process:

1) a std::mutex has undefined behavior if you try to use it to guard
against access from the same thread.  Because of the use of wx event
loops (and coroutines) it is entirely possible, and in some situations
inevitable, that the same thread will try to redraw the ratsnest in the
middle of zone refilling.

2) The mutex was only guarding the ZONE_FILLER::Fill method, but the callers
of that method also do connectivity updates as part of the COMMIT::Push.
Redrawing the ratsnest after the Fill but before the Push will result in
stale connectivity pointers to zone filled areas.

Fixed (1) by switching to a trivial spinlock implementation.  Spinlocks would
generally not be desirable if the contention for the connectivity data crossed
thread boundaries, but at the moment I believe it's guaranteed that the reads
and writes to connectivity that are guarded by this lock happen from the main
UI thread.  The writes are also quite rare compared to reads, and reads are
generally fast, so I'm not really worried about the UI thread spinning for any
real amount of time.

Fixed (2) by moving the locking location up to the call sites of
ZONE_FILLER::Fill.

This issue was quite difficult to reproduce, but I found a fairly reliable way:
It only happens (for me) on Windows, MSYS2 build, with wxWidgets 3.0
It also only happens if I restrict PcbNew to use 2 CPU cores.
With those conditions, I can reproduce the issue described in #6471 by
repeatedly editing a zone properties and changing its net.  The crash is
especially easy to trigger if you press some keys (such as 'e' for edit)
while the progress dialog is displayed.  It's easiest to do this in a debug
build as the slower KiCad is running, the bigger the window is to trigger this
bug.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6471
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7048
2021-01-18 13:22:12 -05:00
..
core Fix issues with zone filling connectivity locking 2021-01-18 13:22:12 -05:00
dialogs Stop bludgeoncompiling dialog_page_settings 2020-12-19 10:40:37 -05:00
gal Don't crash when getting multiple wx calls 2021-01-09 13:05:58 -08:00
kicad_curl Expose curl_easy_escape via KICAD_CURL_EASY 2020-02-20 22:07:17 -05:00
libeval Remove "useMils" variable from numeric evaluator 2020-10-03 20:06:56 +00:00
libeval_compiler Performance improvements for DRC rules. 2021-01-11 22:09:36 +00:00
page_layout Make RENDER_SETTINGS argument const 2021-01-12 20:51:31 +00:00
plugins Add noexcept to some functions in the 3d viewer. 2020-04-16 16:11:21 +00:00
preview_items Appy units updating more consistently to editing assistants. 2020-11-04 14:11:25 +00:00
project Remember autotrack width setting 2021-01-06 20:11:32 -08:00
settings Promote mouse drag settings to full enums. 2021-01-11 22:09:36 +00:00
tool Push shared parts of GRID_HELPERs into common. 2021-01-16 23:18:10 +00:00
view Promote mouse drag settings to full enums. 2021-01-11 22:09:36 +00:00
widgets Dismiss infobar if it's dismissable on board save 2021-01-12 23:24:13 -05:00
advanced_config.h Make small drill marks size configurable via advanced config for both printing and plotting 2021-01-05 22:37:34 +00:00
array_axis.h Pcbnew: add a step field to the array tool 2019-05-16 11:20:52 +01:00
array_options.h Arrays: isolate axis code in a new class 2019-05-16 11:20:52 +01:00
base64.h Plot SVG embedded 2019-12-08 08:57:33 -08:00
base_screen.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
base_units.h Move StripTrailingZeros to kicad_string.h 2020-10-25 00:02:53 -04:00
basic_gal.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
bin_mod.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
bitmap_base.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
bitmap_types.h Move scaled toolbar separator into ACTION_TOOLBAR 2020-06-26 21:29:03 +00:00
bitmaps.h Bitmaps: move bitmap defs to bitmaps library 2019-02-04 19:29:31 -08:00
board_design_settings.h Add more const specifiers 2021-01-12 20:51:31 +00:00
board_item.h Implement locking for graphic shapes. 2021-01-07 17:39:18 +00:00
board_printout.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
build_version.h Move bug reporting to COMMON_CONTROL; add to Help menu 2020-05-26 21:18:32 -04:00
class_draw_panel_gal.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
collector.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
commit.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
common.h Resolve text variables in title blocks for outputing to netlist. 2021-01-17 16:24:22 +00:00
config_map.h Fix a few doxygen warnings 2017-06-20 10:47:30 +02:00
config_params.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
confirm.h Save a cancel value when asked if it's not being used to cancel. 2021-01-08 21:32:19 +00:00
convert_to_biu.h Code cleanup related to zoom: 2020-12-02 18:35:28 +01:00
cursors.h Make Linux/Mac cursors black again 2021-01-05 09:47:17 -08:00
dialog_helpers.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
dialog_shim.h Better sizing for some conditional dialogs. 2021-01-07 01:27:12 +00:00
dsnlexer.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
eda_base_frame.h Show collisions preventing routing from starting. 2021-01-04 19:19:55 +00:00
eda_dde.h Keep track of open sockets and dispose of them in d'tor. 2018-04-04 12:02:40 +01:00
eda_doc.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
eda_draw_frame.h Make RENDER_SETTINGS argument const 2021-01-12 20:51:31 +00:00
eda_item.h Add more const specifiers 2021-01-12 20:51:31 +00:00
eda_pattern_match.h Add group-by-suffix display option in net inspector 2020-11-04 02:49:19 +00:00
eda_rect.h Header clean up round 1. 2020-12-18 09:04:26 -05:00
eda_text.h Minor adjustments 2021-01-12 20:51:31 +00:00
eda_units.h Split EDA_UNITS out from common. 2020-10-25 00:02:52 -04:00
enum_vector.h Comment-only changes 2020-01-10 16:43:01 -08:00
env_paths.h Formatting. 2020-12-13 11:42:03 +00:00
env_vars.h Add configuration of Hi-DPI canvas scaling in OpenGL 2019-03-25 15:00:55 +00:00
executable_names.h Move executable name constants to own file 2017-03-23 09:23:45 -04:00
filehistory.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
filename_resolver.h Change environmental variables to human-readable 2021-01-01 16:20:35 +00:00
fill_type.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
filter_reader.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
footprint_editor_settings.h Deduplicate settings migration handling 2020-10-05 23:21:57 -04:00
footprint_filter.h Cleanup to make implementation names consistent with what they now do. 2019-09-03 19:29:30 +01:00
footprint_info.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
fp_lib_table.h Fix library tree behavior when duplicate project table entry is disabled. 2021-01-11 07:46:07 -05:00
frame_type.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gbr_metadata.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gbr_netlist_metadata.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gestfich.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gl_context_mgr.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gl_utils.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gr_basic.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
gr_text.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
grid_tricks.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
hash_eda.h First-class support for filled shapes. 2020-11-14 01:40:32 +00:00
hashtables.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
hotkey_store.h Add missing include 2020-10-24 00:44:25 -04:00
hotkeys_basic.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
i18n_utility.h Try to fix a compil issue on OSX (no viable conversion from 'const wxString' to 'const wxChar *', in colors.cpp) 2016-05-17 09:10:15 +02:00
id.h Update Lanugage list with new contributions 2021-01-06 14:23:59 -08:00
import_export.h Use _WIN32 instead of __MINGW32__ in 2 conditional compilations which are Windows specific, not especially mingw32 specific. 2016-03-01 16:55:44 +01:00
inspectable.h INSPECTABLE: minor bugfix 2020-07-05 22:44:38 +02:00
intrusive_list.h Moved INTRUSIVE_LIST to a separate header 2017-06-23 18:51:00 +02:00
ki_exception.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kicad_string.h pcbnew: Add Fabmaster import 2021-01-16 14:28:33 -08:00
kiface_i.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kiface_ids.h eeschema: allow exporting netlists through UI-less KIFACE API function 2020-09-27 16:45:46 +02:00
kiid.h Split KIID out of common.h 2020-10-24 00:17:08 -04:00
kiway.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kiway_express.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kiway_holder.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kiway_mgr.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
kiway_player.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
launch_ext.h Fix URL launching on MacOS 2020-02-22 09:47:51 -05:00
layers_id_colors_and_visibility.h Remove macros.h from files that don't need it 2020-10-24 08:28:02 -04:00
lib_id.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
lib_table_base.h Fix library tree behavior when duplicate project table entry is disabled. 2021-01-11 07:46:07 -05:00
lib_table_grid.h Generalize default footprint fields. 2020-05-08 23:30:33 +01:00
lib_tree_item.h Split base_struct into eda_item and eda_rect 2020-10-13 21:24:50 -04:00
lib_tree_model.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
lib_tree_model_adapter.h Fix crash when deleting symbol in GTK 2021-01-04 09:15:40 -08:00
locale_io.h Move LOCALE_IO out of common.h 2020-10-23 21:49:42 -04:00
lockfile.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
logging.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
macros.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
macros_swig.h Split KIID out of common.h 2020-10-24 00:17:08 -04:00
mail_type.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
marker_base.h Make RENDER_SETTINGS argument const 2021-01-12 20:51:31 +00:00
menus_helpers.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
multivector.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
netclass.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
newstroke_font.h Fix incorrect (too small) bounding box EDA_TEXT, noticeable when chars like j or { are used in zone fill functions. 2016-03-11 13:08:34 +01:00
observable.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
origin_transforms.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
origin_viewitem.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
outline_mode.h python wrap: fix undefined FILLED/SKETCH constants in pcbnew.py 2020-10-21 13:23:06 +02:00
pad_shapes.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
page_info.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
painter.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
panel_hotkeys_editor.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
panel_text_variables.h Variable substitution framework. 2020-03-30 14:15:59 +01:00
pcb_base_frame.h Use color theme backgrounds in page previews. 2020-12-23 23:18:38 +00:00
pcb_display_options.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
pcb_group.h Add more const specifiers 2021-01-12 20:51:31 +00:00
pcb_screen.h Header clean up round 3. 2020-12-19 18:29:10 -05:00
pgm_base.h Initialize translation dictionary to default 2021-01-12 13:33:40 -08:00
plotter.h Naming conventions. 2020-11-16 00:04:55 +00:00
plotters_specific.h Standardize PostScript capitalizaiton 2020-10-20 13:09:13 -07:00
printout.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
profile.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
project.h Header clean up round 2. 2020-12-19 13:55:28 -05:00
properties.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
property.h Fix compiler warning the old fashioned way. (Remove the code.) 2020-12-21 19:47:36 +00:00
property_mgr.h Remove common.h from more headers 2020-10-25 22:29:53 -04:00
ptree.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
rc_item.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
refdes_utils.h Break out ref-des-centric functions to own header 2019-01-30 15:41:36 -08:00
render_settings.h Add more const specifiers 2021-01-12 20:51:31 +00:00
reporter.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
richio.h Minor adjustments 2021-01-12 20:51:31 +00:00
scintilla_tricks.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
scoped_set_reset.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
search_stack.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
status_popup.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
streamwrapper.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
sync_queue.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
systemdirsappend.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
template_fieldnames.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
textentry_tricks.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
title_block.h Move title block fields to global availability in PCBNew. 2021-01-15 15:41:18 +00:00
trace_helpers.h Catch exception when creating app settings objects 2020-09-21 12:07:51 +01:00
undo_redo_container.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
utf8.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
validators.h Unify LIB_IDs now that both are stored in sexpr files. 2020-12-18 00:30:26 +00:00
wildcards_and_files_ext.h ADDED: CADSTAR Archive project importer 2020-09-27 23:50:20 +00:00
wx_filename.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
wxdataviewctrl_helpers.h Move wxDataViewCtrl manipulators out of dialog_choose_component.cpp 2017-03-30 21:47:14 -04:00
xnode.h Header clean up round 4. 2020-12-21 10:18:10 -05:00
zoom_defines.h Code cleanup related to zoom: 2020-12-02 18:35:28 +01:00