[Tile-serving] [osm2pgsql] Core dump with test files and multi-backend (#334)

Paul Norman notifications at github.com
Sat Apr 18 06:26:42 UTC 2015


with 

`test_output_multi_tags.json`
```json
[
  {
    "name": "test_points_1",
    "type": "point",
    "tagtransform": "tests/test_output_multi_tags.lua",
    "tagtransform-node-function": "test_nodes_1",
    "tagtransform-way-function": "drop_all",
    /* No relations in the file */
    "tagtransform-relation-function": "drop_all",
    "tagtransform-relation-member-function": "drop_all",
    "tags": [
      {"name": "foo", "type": "text"},
      {"name": "bar", "type": "text"},
      {"name": "baz", "type": "text"} /* left empty by the transform */
    ]
  },
  {
    /* This second table will process the same data, but resulting in different tags */
    "name": "test_points_2",
    "type": "point",
    "tagtransform": "tests/test_output_multi_tags.lua",
    "tagtransform-node-function": "test_nodes_2",
    "tagtransform-way-function": "drop_all",
    /* No relations in the file */
    "tagtransform-relation-function": "drop_all",
    "tagtransform-relation-member-function": "drop_all",
    "tags": [
      {"name": "foo", "type": "text"},
      {"name": "bar", "type": "text"}, /* left empty by the transform */
      {"name": "baz", "type": "text"}
    ]
  }
]
```
`test_output_multi_tags.lua`
```lua
function drop_all (...)
  return 1, {}
end

function test_nodes_1 (kv, num_tags)
  if kv["foo"] then
    tags = {}
    tags["bar"] = kv["foo"]
    return 0, tags
  else
    return 1, {}
  end
end

function test_nodes_2 (kv, num_tags)
  if kv["foo"] then
    tags = {}
    tags["baz"] = kv["foo"]
    return 0, tags
  else
    return 1, {}
  end
end
```
`test_output_multi_tags.osm`
```xml
<osm version="0.6">
<!--
 43
 21
-->
 <node id="1" lat="49.00" lon="-123.00">
 <tag k="foo" v="n1"/>
 </node>
 <node id="2" lat="49.00" lon="-123.01"/>
 <node id="3" lat="49.01" lon="-123.00"/>
 <node id="4" lat="49.01" lon="-123.01"/>
 <way id="1">
  <nd ref="1"/>
  <nd ref="2"/>
 <tag k="foo" v="w1"/>
 </way>
 <way id="2">
  <nd ref="1"/>
  <nd ref="3"/>
  <nd ref="4"/>
  <nd ref="1"/>
 <tag k="foo" v="w2"/>
 </way>
</osm>
```

when I ran the command `./osm2pgsql -d osm2pgsqltest -O multi -S tests/test_output_multi_tags.json tests/test_output_multi_tags.osm` I got the output
```
Committing transaction for test_points_1
WARNING:  there is no transaction in progress
Committing transaction for test_points_2
WARNING:  there is no transaction in progress
Sorting data and creating indexes for test_points_1
Sorting data and creating indexes for test_points_2
node cache: stored: 4(100.00%), storage efficiency: 0.39% (dense blocks: 1, sparse nodes: 0), hit rate: nan%
Copying test_points_2 to cluster by geometry finished
Creating geometry index on  test_points_2
Copying test_points_1 to cluster by geometry finished
Creating geometry index on  test_points_1
Creating indexes on  test_points_2 finished
Creating indexes on  test_points_1 finished
Abort trap (core dumped)
```

A backtrace puts it at
```
  0x0000000802eee6ca in thr_kill () from /lib/libc.so.7
[New Thread 804007400 (LWP 101038/osm2pgsql)]
[New Thread 804007000 (LWP 101037/osm2pgsql)]
[New Thread 804006400 (LWP 100843/osm2pgsql)]
(gdb) bt
#0  0x0000000802eee6ca in thr_kill () from /lib/libc.so.7
#1  0x0000000802fc3149 in abort () from /lib/libc.so.7
#2  0x000000080284442d in __cxa_rethrow () from /lib/libcxxrt.so.1
#3  0x00000000004810e6 in pgsql_exec_simple (sql_conn=<value optimized out>, expect=<value optimized out>, sql=0x7fffff7fb6e9 "ANALYZE test_points_1")
    at pgsql.cpp:44
#4  0x0000000000480eef in pgsql_exec_simple (sql_conn=0x6, expect=PGRES_EMPTY_QUERY, sql=<value optimized out>) at pgsql.cpp:32
#5  0x0000000000489fde in table_t::stop (this=0x8040a4280) at table.cpp:256
#6  0x000000000046438b in output_multi_t::stop (this=0x804038120) at output-multi.cpp:147
#7  0x00000008023634a5 in boost::thread::start_thread_noexcept () from /usr/local/lib/libboost_thread.so.1.55.0
#8  0x0000000802c654f5 in pthread_create () from /lib/libthr.so.3
#9  0x0000000000000000 in ?? ()
```

The C++ is
```c++
boost::shared_ptr<PGresult> pgsql_exec_simple(PGconn *sql_conn, const ExecStatusType expect, const char *sql)
{
    PGresult* res;
#ifdef DEBUG_PGSQL
    fprintf( stderr, "Executing: %s\n", sql );
#endif
    res = PQexec(sql_conn, sql);
    if (PQresultStatus(res) != expect) {
        PQclear(res);
        throw std::runtime_error((boost::format("%1% failed: %2%\n") % sql % PQerrorMessage(sql_conn)).str());
    }
    return boost::shared_ptr<PGresult>(res, &PQclear);
}
```
The line it's got a core dump on is the throw. Probably related to #298 in cause of the PG error.

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/334
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20150417/151f5592/attachment-0001.html>


More information about the Tile-serving mailing list