node-mapnik icon indicating copy to clipboard operation
node-mapnik copied to clipboard

node-mapnik segfaults on node 20.12 onwards

Open tstibbs opened this issue 1 year ago • 3 comments

Problem description

In the latest minor release of the current active LTS version (node 20), mapnik causes a segfault.

it's broken in:

  • 20.x (which is the 'active' LTS branch) from 20.12.0 onwards
  • 21.x from 21.7.0 onwards
  • 22.x from 22.2.0 onwards (thanks @Phyks for reporting this)

it's not broken in

  • 18.x

Other environment notes: Reproduced in ubuntu and debian; in github actions, docker and WSL.

To reproduce

Create file package.json:

{
	"dependencies": {
		"mapnik": "4.5.9"
	}
}

Create file test.js:

require('mapnik').register_default_input_plugins()

Run the following:

npm install
node test.js

Expected output: none

Actual output: aborts execution, prints "Segmentation fault", sets non-zero exit code.

tstibbs avatar May 07 '24 19:05 tstibbs

For what it's worth, I'm experiencing the same issue on Arch Linux with node v22.2.0.

Stack trace when running npm i with node-mapnik as a dependency (then, node-mapnik v. 4.5.9 from npm registry) is:

mai 29 11:01:57 Phyks-laptop systemd-coredump[31784]: [🡕] Process 31773 (kosmtik) of user 1000 dumped core.

                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/libmapnik.so without build-id.
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/libmapnik.so
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input without build-id.
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/csv.input without build-id.
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/csv.input
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/mapnik.node without build-id.
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/mapnik.node
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/geojson.input without build-id.
                                                      Module /home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/geojson.input
                                                      Stack trace of thread 31773:
                                                      #0  0x000079fe4bab7da1 __libc_free (libc.so.6 + 0xa3da1)
                                                      #1  0x000079fe40e2b264 n/a (/home/phyks/Utilities/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input + 0x2b264)
                                                      ELF object binary architecture: AMD x86-64

Phyks avatar May 29 '24 09:05 Phyks

@Phyks @tstibbs I can replicate with some node versions on Ubuntu 24.04 LTS

For example it works with current node --lts

nvm ls
       v18.20.3
       v20.12.2
->     v20.15.0
        v22.3.0
default -> lts/* (-> v20.15.0)
node 
Welcome to Node.js v20.15.0.
Type ".help" for more information.
> var m = require("mapnik");
undefined
> m.register_datasource("node_modules/mapnik/lib/binding/lib/mapnik/input/sqlite.input");
true
> m.register_default_input_plugins()
undefined
> m.datasources()
[
  'csv',      'gdal',
  'geobuf',   'geojson',
  'ogr',      'pgraster',
  'postgis',  'raster',
  'shape',    'sqlite',
  'topojson'
]

but segfaults with v22.3.0

artemp avatar Jul 01 '24 16:07 artemp

@Phyks @tstibbs - v4.6.0-rc1 should work with all node versions >= 18

https://github.com/mapnik/node-mapnik/pkgs/npm/mapnik

artemp avatar Jul 01 '24 16:07 artemp

@artemp, is it private tho? How can I get access?

snorkysnark avatar Aug 03 '24 23:08 snorkysnark

@artemp, is it private tho? How can I get access?

FYI, latest is v4.6.0-rc2. Follow GitHub docs for now to access etc https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry

var mapnik = require('@mapnik/mapnik'); 

artemp avatar Aug 04 '24 14:08 artemp

@tstibbs Closing as fixed

artemp avatar Aug 19 '24 08:08 artemp