Page 1 of 1

problem with minetestmapper

PostPosted: Wed Feb 15, 2017 11:59
by linushsao
hi,all i always got error message while generate map by minetestmapper:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
GD Warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully


how should you generate map?

Re: problem with minetestmapper

PostPosted: Wed Feb 15, 2017 13:30
by Beerholder
How big is the world you want to map? From the looks of it the resulting image would be too large so LibGD exits before it would crash trying to process the image. Larger image sizes using 64 bit support is scheduled for GD release 2.3 and it will probably take quite a while before that is released. Maybe you can generate tiles using the --geometry option to avoid running into this problem? E.g. from the docs:

./minetestmapper --geometry -10000:-10000+20000+20000 -i /etc/etc

And then use e.g. ImageMagick to stitch the tiles using -append and +append?

Re: problem with minetestmapper

PostPosted: Wed Feb 15, 2017 17:04
by Sergey
I made map of square size 10km x 10km with origin in the center. Generation took much time but no errors occured.
The size of generated PNG file was about 92Mb.

Re: problem with minetestmapper

PostPosted: Thu Feb 16, 2017 10:48
by Beerholder
Size on disk does not equal size in memory since PNG uses compression whereas LibGD needs to have the full image in memory. For a 10k x 10k that would be roughly 100MB times 4 as there are 4 channels, RGB and A (alpha) which is 400MB in memory. The relevant buffer overflow protection is here: https://github.com/libgd/libgd/blob/mas ... rity.c#L27

Call to overflow2 for PNG images is here https://github.com/libgd/libgd/blob/mas ... png.c#L417

So as per this code rowbytes (a) would be 10000 pixels x 4 channels = 40000 (RGBA) and height (b) is 10000 pixels. Then (a > INT_MAX / b) => 40000 > 2147483647 / 10000 => 40000 > 214748 which is false. In general, rowbytes x height should not exceed INT_MAX. FYI the max size before the overflow check would fail will be a little over 23k x 23k, and more generally height x width x 4 must remain < 2GB.