use-after-free in editor
Bug #1735980 reported by
GunChleoc
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Critical
|
Unassigned |
Bug Description
Found 2 instances of use-after-free/segv in the editor:
- save map
- undo: initialize resources when map origin has been changed
Related branches
lp://staging/~widelands-dev/widelands/fix-bug-1735980-related-problems
- Klaus Halfmann: Approve (compile, review, test)
- GunChleoc: Approve
- kaputtnik (community): Approve (testing)
-
Diff: 35 lines (+12/-2)2 files modifiedsrc/editor/tools/set_origin_tool.cc (+9/-1)
src/logic/map.cc (+3/-1)
description: | updated |
tags: | added: editor |
description: | updated |
Changed in widelands: | |
assignee: | GunChleoc (gunchleoc) → nobody |
Changed in widelands: | |
status: | New → Fix Committed |
To post a comment you must log in.
To reproduce the bug with the resources tool:
1. Place some water on the map
2. Add fish
3. Change the map origin
4. Hit the undo button twice
The underlying problem here is that undo stops working for all editor tools once the map origin changes. The other tools simply won't undo anything (or maybe undo something in the wrong location?)
==29319==ERROR: AddressSanitizer: heap-use-after-free on address 0x63300005a349 at pc 0x000000fb7e40 bp 0x7ffc300a1910 sp 0x7ffc300a1900 :Map::initializ e_resources( Widelands: :FCoords const&, unsigned char, unsigned char) /home/bratzbert /sources/ widelands/ asan/src/ logic/map. cc:1819 cesTool: :handle_ undo_impl( Widelands: :World const&, Widelands: :NodeAndTriangl e<Widelands: :Coords, Widelands::Coords> const&, EditorInteractive&, EditorActionArgs*, Widelands::Map*) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/set_ resources_ tool.cc: 75 esourcesTool: :handle_ undo_impl( Widelands: :World const&, Widelands: :NodeAndTriangl e<Widelands: :Coords, Widelands::Coords> const&, EditorInteractive&, EditorActionArgs*, Widelands::Map*) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/increase_ resources_ tool.cc: 71 :handle_ undo(EditorTool ::ToolIndex, Widelands::World const&, Widelands: :NodeAndTriangl e<Widelands: :Coords, Widelands::Coords> const&, EditorInteractive&, EditorActionArgs*, Widelands::Map*) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/tool. h:70 :undo_action( Widelands: :World const&) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/history. cc:67 /sources/ widelands/ asan/src/ editor/ editorinteracti ve.cc:133
WRITE of size 1 at 0x63300005a349 thread T0
#0 0xfb7e3f in Widelands:
#1 0xe2e2da in EditorSetResour
#2 0xe23344 in EditorIncreaseR
#3 0xe172dd in EditorTool:
#4 0xe1870e in EditorHistory:
#5 0xdd2bc0 in operator() /home/bratzbert
0x63300005a349 is located 23369 bytes inside of 106496-byte region [0x633000054800 ,0x63300006e800 ) x86_64- linux-gnu/ libasan. so.2+0x99caa) delete< Widelands: :Field []>::operator( )(Widelands: :Field* ) const /usr/include/ c++/5/bits/ unique_ ptr.h:119 ptr<Widelands: :Field [], std::default_ delete< Widelands: :Field []> >::reset( Widelands: :Field* ) /usr/include/ c++/5/bits/ unique_ ptr.h:581 :Map::set_ origin( Widelands: :Coords const&) /home/bratzbert /sources/ widelands/ asan/src/ logic/map. cc:362 Tool::handle_ click_impl( Widelands: :World const&, Widelands: :NodeAndTriangl e<Widelands: :Coords, Widelands::Coords> const&, EditorInteractive&, EditorActionArgs*, Widelands::Map*) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/set_ origin_ tool.cc: 31 :handle_ click(EditorToo l::ToolIndex, Widelands::World const&, Widelands: :NodeAndTriangl e<Widelands: :Coords, Widelands::Coords> const&, EditorInteractive&, EditorActionArgs*, Widelands::Map*) /home/bratzbert /sources/ widelands/ asan/src/ editor/ tools/tool. h:60 :do_action( EditorTool& , EditorTool: :ToolIndex, Widelands::Map&, Widelands::World const&, Widelands:...
freed by thread T0 here:
#0 0x7fd14bcb1caa in operator delete[](void*) (/usr/lib/
#1 0xfc3258 in std::default_
#2 0xfbf642 in std::unique_
#3 0xfb01dc in Widelands:
#4 0xe2bd0f in EditorSetOrigin
#5 0xe17123 in EditorTool:
#6 0xe1900f in EditorHistory: