Skip to content

Commit 280db8c

Browse files
committed
Fix segfault when using LuaJIT
For some reason LuaJIT doesn't like the "noexcept" on our trampoline function. Fixes #1070.
1 parent 8b3c3cb commit 280db8c

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

src/output-flex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static std::mutex lua_mutex;
4242
// context (the output_flex_t object) and call the respective function on the
4343
// context object.
4444
#define TRAMPOLINE(func_name, lua_name) \
45-
static int lua_trampoline_##func_name(lua_State *lua_state) noexcept \
45+
static int lua_trampoline_##func_name(lua_State *lua_state) \
4646
{ \
4747
try { \
4848
return static_cast<output_flex_t *>(luaX_get_context(lua_state)) \

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if (HAVE_LUA)
7373
set_test(test-output-flex-area)
7474
set_test(test-output-flex-attr)
7575
set_test(test-output-flex-extra)
76+
set_test(test-output-flex-lua-fail)
7677
set_test(test-output-flex-uni)
7778
set_test(test-output-flex-tablespace LABELS Tablespace)
7879
set_test(test-output-flex-update)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
local table = osm2pgsql.define_table{
3+
name = 'osm2pgsql_test_polygon',
4+
ids = { type = 'area', id_column = 'osm_id' },
5+
columns = {
6+
{ column = 'tags', type = 'hstore' },
7+
{ column = 'name', type = 'text' },
8+
{ column = 'geom', type = 'geometry' },
9+
{ column = 'area', type = 'area' },
10+
}
11+
}
12+
13+
function is_empty(some_table)
14+
return next(some_table) == nil
15+
end
16+
17+
function clean_tags(tags)
18+
tags.odbl = nil
19+
tags.created_by = nil
20+
tags.source = nil
21+
tags['source:ref'] = nil
22+
tags['source:name'] = nil
23+
end
24+
25+
function osm2pgsql.process_way(data)
26+
clean_tags(data.tags)
27+
if is_empty(data.tags) then
28+
return
29+
end
30+
31+
table:add_row({
32+
tags = data.tags,
33+
name = data.tags.name,
34+
})
35+
end
36+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <catch.hpp>
2+
3+
#include "common-import.hpp"
4+
#include "common-options.hpp"
5+
6+
static testing::db::import_t db;
7+
8+
TEST_CASE("error in lua file")
9+
{
10+
REQUIRE_THROWS(
11+
db.run_file(testing::opt_t().slim().flex("test_output_flex_fail.lua"),
12+
"liechtenstein-2013-08-03.osm.pbf"));
13+
}
14+

0 commit comments

Comments
 (0)