osm2pgsql - Segmentation Fault while Reading File

I’m getting a Segmentation Fault while running osm2pgsql. Running on Amazon Ec2, Amazon Linux AMI. Problem also occures when running under Fedora btw. Did compile osm2pgswl from source, as well as postgis, proj en geos. PostgreSQL comes from the yum repo.

I run osm2pgsql with the following parameters:

osm2pgsql -l -s -C 200 /mnt/data/austria.osm 

The output is:

osm2pgsql SVN version 0.80.0 (32bit id space)

Using projection SRS 4326 (Latlong)
Setting up table: planet_osm_point
NOTICE:  table "planet_osm_point" does not exist, skipping
NOTICE:  table "planet_osm_point_tmp" does not exist, skipping
Setting up table: planet_osm_line
NOTICE:  table "planet_osm_line" does not exist, skipping
NOTICE:  table "planet_osm_line_tmp" does not exist, skipping
Setting up table: planet_osm_polygon
NOTICE:  table "planet_osm_polygon" does not exist, skipping
NOTICE:  table "planet_osm_polygon_tmp" does not exist, skipping
Setting up table: planet_osm_roads
NOTICE:  table "planet_osm_roads" does not exist, skipping
NOTICE:  table "planet_osm_roads_tmp" does not exist, skipping
Allocating memory for dense node cache
Allocating dense node cache in block sized chunks
Node-cache: cache=200MB, maxblocks=0*25601, allocation method=8192
Mid: pgsql, scale=10000000
Setting up table: planet_osm_nodes
NOTICE:  table "planet_osm_nodes" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_nodes_pkey" for table "planet_osm_nodes"
Setting up table: planet_osm_ways
NOTICE:  table "planet_osm_ways" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_ways_pkey" for table "planet_osm_ways"
Setting up table: planet_osm_rels
NOTICE:  table "planet_osm_rels" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_rels_pkey" for table "planet_osm_rels"

Reading in file: /mnt/data/austria.osm
Segmentation fault

The /var/log/messages says:

kernel: [ 1008.212485] osm2pgsql[1476]: segfault at 180005dc ip 08061324 sp bffa7d70 error 4 in osm2pgsql[8048000+20000]

Thing is, when adding -O null (no output) osm2pgsql starts converting. So I guess it has something to do with Postgres, but I really have no clue.

Anyone can help me where to look next?

I did a backtrace and it confirms my hunch it was the connection with PGSQL:

Program received signal SIGSEGV, Segmentation fault.
0x08061324 in ram_cache_nodes_set_dense (id=1, lat=51.249215200000002, lon=9.4317165999999997, tags=0x806a578) at node-ram-cache.c:191
191        if (!blocks[block].nodes) {
(gdb) bt
#0  0x08061324 in ram_cache_nodes_set_dense (id=1, lat=51.249215200000002, lon=9.4317165999999997, tags=0x806a578) at node-ram-cache.c:191
#1  ram_cache_nodes_set (id=1, lat=51.249215200000002, lon=9.4317165999999997, tags=0x806a578) at node-ram-cache.c:457
#2  0x080560b2 in pgsql_nodes_set (id=1, lat=51.249215200000002, lon=9.4317165999999997, tags=0x806a578) at middle-pgsql.c:425
#3  0x08051734 in pgsql_add_node (id=1, lat=51.249215200000002, lon=9.4317165999999997, tags=0x806a578) at output-pgsql.c:1519
#4  0x0805bbbe in EndElement (name=<value optimized out>, osmdata=0x806a540) at parse-xml2.c:270
#5  0x0805bdcb in processNode (filename=0xbffff717 "/mnt/data/europe.osm.bz2", sanitize=0, osmdata=0x806a540) at parse-xml2.c:357
#6  streamFileXML2 (filename=0xbffff717 "/mnt/data/europe.osm.bz2", sanitize=0, osmdata=0x806a540) at parse-xml2.c:382
#7  0x08057f3a in main (argc=6, argv=0xbffff5a4) at osm2pgsql.c:629
(gdb) 

Might be a corrupted OSM file as well, but tried multiple sources and files

Never mind everyone, I was running a micro instance on EC2 to do some testing. It is working on a high CPU instance. Will send this in as a comment to the WIki

Hi,

Just for anyone else having the same problem, I experienced the exact same error, on a EC2 micro instance.
I made it work by compiling it from source :

EC2 ubuntu package version :


>osm2pgsql -V
osm2pgsql SVN version 0.80.0 (32bit id space)

Compiled version :


./osm2pgsql -V
osm2pgsql SVN version 0.81.0 (64bit id space)

May be a memory space addressing issue (32 vs 64)…

Anyway, works well now !!

Cheers !!