← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/campaign_data into lp:widelands

 

Trying to debug this is not easy, I still do not understand that code:

I run:
> ./regression_test.py -b ./widelands -n -k -r test_campaign_data
I checked the outout in
> /var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_test/WidelandsTestCase/stdout_00.txt
I had to tweak the file to replace \n by real newline to make it readable.

'b'Trying to run: map:scripting/init.lua: Forcing flag at (10, 11)
'b'Forcing flag at (23, 26)
'b'Message: adding warehouse for player 1 at (22, 25)
'b'done
'b'Trying to run: test/maps/plain.wmf/scripting/test_campaign_data.lua: done
'b'Writing campaign data...
'b'Done.
'b'Reading campaign data...
'b'=================================================================
'b'==17300==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffee08c4261 at pc 0x000113d4bc35 bp 0x7ffee08c3990 sp 0x7ffee08c3138
'b'READ of size 3 at 0x7ffee08c4261 thread T0
...
'b'    #6 0x11184300a in Section::has_val(char const*) const profile.cc:216
'b'    #7 0x11141d4e2 in LuaBases::push_table_recursively(lua_State*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Section*, Section*, Section*, Section*) lua_bases.cc:431
'b'    #8 0x111419e16 in LuaBases::LuaEditorGameBase::read_campaign_data(lua_State*) lua_bases.cc:488

So that code reads some variable from a stack that has already been freed.

Benedikt:
* Please add more comments to push_table_recursively(). What is pushed from where?
* I could not locate the file campaigns/test_suite_campaign_data/test_suite_campaign_data.wcd
  where should I find this?

I assume profile.get_section("xxxx") returns a pointer to a local variable,
which is always a bad idea. I found this function with more then one section 
at a time is used only by your code. I had expected that the compiler will give
a warning, but Clang does not?

Can anybody give me some more hints how this Profile class should be used?


-- 
https://code.launchpad.net/~widelands-dev/widelands/campaign_data/+merge/343783
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/campaign_data.


References