Skip to content

Instantly share code, notes, and snippets.

local function dangerous_mutate_table(t, f)
for i, v in ipairs(t) do t[i] = f(v, i) end
end
parent = {}
parent[1] = {}
dangerous_mutate_table(parent, function(v)
v.prop = "asdf"
-- oops, the programmer forgot to return anything here
end)
local parent = {}
parent[1] = {}
mutate_table(parent, function(v)
v.prop = "asdf"
end)
parent[1].prop -- has been set to "asdf"
local function mutate_table(t, f)
for i, v in ipairs(t) do f(v, i) end
end
local function create_tables(count)
local parent_table = {}
for i = 1, count do
table.insert(parent_table, {})
end
return parent_table
end
local function next_node(self)
-- implementation here
end
local summer = {}
summer.next = next_node
local winter = {}
winter.next = next_node
local next_season = summer:next()
clang++ -o wesnoth -pthread -O3 -flto=thin -fuse-ld=lld -Wl,--whole-archive build/release/libwesnoth-widgets.a -Wl,--no-whole-archive build/release/wesnoth.o build/release/libwesnoth-client.a build/release/liblua.a build/release/libwesnoth-core.a build/release/libwesnoth-game.a build/release/libwesnoth-sdl.a build/release/libwesnoth-client.a -lm -lcrypto -lboost_iostreams -lpthread -lboost_system -lboost_random -lboost_filesystem -lboost_locale -lSDL2 -lSDL2_ttf -lSDL2_mixer -lSDL2_image -lvorbisfile -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lfontconfig -lfreetype -lboost_program_options -lboost_thread -lboost_regex -lX11 -ldbus-1 -lfribidi -lpng -lhistory
/usr/bin/ld.lld: error: build/release/libwesnoth-widgets.aaddon_list.o0:(function gui2::implementation::parse_visibility(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)): undefined symbol 'throw_wml_exception(char const*, char const*, int, char const*, std::__cxx11::basic_string<char, std::char_tr
@jyrkive
jyrkive / gist:8550187eb37de756cdc6b8e2fd999f50
Created September 23, 2017 12:46
Wesnoth crash with SDL 2.0.6
Thread 1 "wesnoth-debug" received signal SIGSEGV, Segmentation fault.
SDL_ConvertSurface_REAL (surface=surface@entry=0x555557480d70, format=format@entry=0x5555574813b0,
flags=flags@entry=0) at /home/jyrki/wesnoth/SDL2-2.0.6/src/video/SDL_surface.c:937
937 copy_color.r = surface->map->info.r;
(gdb) bt
#0 SDL_ConvertSurface_REAL (surface=surface@entry=0x555557480d70,
format=format@entry=0x5555574813b0, flags=flags@entry=0)
at /home/jyrki/wesnoth/SDL2-2.0.6/src/video/SDL_surface.c:937
#1 0x00007ffff7b689e7 in SDL_ConvertSurfaceFormat_REAL (surface=surface@entry=0x555557480d70,
pixel_format=pixel_format@entry=372645892, flags=flags@entry=0)
src/scripting/lua_audio.cpp: In function ‘int impl_track_get(lua_State*)’:
src/scripting/lua_audio.cpp:237:12: error: the compiler can assume that the address of ‘track’ will never be NULL [-Werror=address]
if(&track == nullptr || !track->valid()) {
~~~~~~~^~~~~~~~~~
src/scripting/lua_audio.cpp: In function ‘int impl_track_set(lua_State*)’:
src/scripting/lua_audio.cpp:269:12: error: the compiler can assume that the address of ‘track’ will never be NULL [-Werror=address]
if(&track == nullptr || !track->valid()) {
~~~~~~~^~~~~~~~~~
@jyrkive
jyrkive / gist:30ec41535b1bcd199a381073d9ace062
Created July 27, 2017 17:15
Unit test segfault backtrace
Thread 3 "test-debug" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f473cb4c700 (LWP 26344)]
0x00007f474e617dfb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007f474e617dfb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f474eead538 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x000000010032fe76 in std::operator< <char, std::char_traits<char>, std::allocator<char> > (
__lhs=..., __rhs=...) at /usr/include/c++/6/bits/basic_string.h:5153
#3 0x0000000100331cb7 in std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::operator() (this=0x101d2c2e0 <file_number_map>, __x=..., __y=...)
at /usr/include/c++/6/bits/stl_function.h:386
@jyrkive
jyrkive / gist:73a19ad6474e83d84682e3904838ebbd
Created July 24, 2017 20:17
Attempt to render in unit tests
Thread 1 "test-debug" received signal SIGFPE, Arithmetic exception.
0x00000001010373bc in display::draw_wrap (this=0x101da4240, update=true, force=true)
at src/display.cpp:1678
1678 time_between_draws = 1000 / screen_.current_refresh_rate();
(gdb) bt
#0 0x00000001010373bc in display::draw_wrap (this=0x101da4240, update=true, force=true)
at src/display.cpp:1678
#1 0x000000010103ab1f in display::draw (this=0x101da4240, update=true, force=true)
at src/display.cpp:2467
#2 0x000000010103a77c in display::redraw_everything (this=0x101da4240) at src/display.cpp:2386