mapnik / node-mapnik

Bindings to mapnik for node.js
http://mapnik.org/documentation/node-mapnik
BSD 3-Clause "New" or "Revised" License
533 stars 165 forks source link

node-mapnik segfaults on node 20.12 onwards #995

Closed tstibbs closed 3 months ago

tstibbs commented 6 months ago

Problem description

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

it's broken in:

it's not broken in

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.

Phyks commented 5 months ago

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
artemp commented 4 months ago

@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 commented 4 months ago

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

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

snorkysnark commented 3 months ago

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

artemp commented 3 months ago

@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 commented 3 months ago

@tstibbs Closing as fixed