🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.debian.bugs.dist
3 messages
3 total messages Started by Florian Lohoff Sat, 14 Nov 2026 08:30
Bug#1153953: tilemaker: allocator race crashes in 3.0.0-1 in trixie/stable
#4456
Author: Florian Lohoff
Date: Sat, 14 Nov 2026 08:30
158 lines
7657 bytes
--Ty6EhoN8Js7ptVKO
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Package: tilemaker
Version: 3.0.0-1
Tags: patch

Hi,
First ... thanks for maintaining tilemaker in Debian ..

I am running tilemaker in a Debian/Trixie based Docker container i built=20
myself every 30 minutes on a pretty small input. I saw occasional crashes of
tilemaker (Every 2-3 days)

I added instrumentation to push the coredump to safe store when it
happened.

With the help of sonnet i found at least 2 allocator races in tilemaker=20
3.0.0-1 - At least the first one is fixed in current git upstream=20
although the code has changed completely.

As these present crashes i though i at least document a way around in=20
the Debian bug tracker for Debian/Trixie e.g. stable for others
who trigger this.

I locally rebuilt the package for the Docker container with these two=20
patches:

This is the first race i found which is also fixed in upstream git.


Description: Lock region mutex when freeing from the thread's own mmap regi=
on
  destroy() skipped the region mutex for the calling thread's own region,
  racing with other threads freeing into it (e.g. BinarySearchNodeStore
  deque growth). This corrupts the allocator state and can crash.
Forwarded: no

--- a/src/mmap_allocator.cpp
+++ b/src/mmap_allocator.cpp
@@ -223,6 +223,7 @@
  	if(mmap_shm_thread_region_ptr !=3D nullptr) {=09
  		auto &i =3D *mmap_shm_thread_region_ptr;
  		if(p >=3D (void const *)i.region.data()  && p < reinterpret_cast<void c=
onst *>(reinterpret_cast<uint8_t const *>(i.region.data()) + i.region.size(=
))) {
+			std::lock_guard<std::mutex> lock(i.mutex);
  			allocator_t allocator(i.buffer.get_segment_manager());
  			return allocator.destroy(reinterpret_cast<uint8_t *>(p));
  		}
@@ -231,6 +232,7 @@
  	if(mmap_file_thread_ptr !=3D nullptr) {=09
  		auto &i =3D *mmap_file_thread_ptr;
  		if(p >=3D i.region.get_address()  && p < reinterpret_cast<void const *>=
(reinterpret_cast<uint8_t const *>(i.region.get_address()) + i.region.get_s=
ize())) {
+			std::lock_guard<std::mutex> lock(i.mutex);
  			allocator_t allocator(i.buffer.get_segment_manager());
  			allocator.destroy(reinterpret_cast<uint8_t *>(p));
  			return;



The second crash and fix i found was this - Its still in upstream=20
tilemaker although the code changed significantly and the race is more
unlikely as upstream changed to std::dequeue - This solution
allocates a static array of 2**24 pointers - This only increases VSZ
when not touching them. Advantage is that no locking on read is
necessary which is missing in 3.0.0-1 and in upstream.



Description: Fix data race on PooledString table vector
  tables[tableIndex] was read without a lock while another thread
  push_back()ed (reallocating), yielding a garbage pointer in memcpy.
  Use a fixed, never-reallocated table instead.
  .
  Crash (SIGSEGV, tilemaker 3.0.0-1, --input grid.pbf):
  .
   #0 libc memcpy (vmovdqu %xmm0,(%rdi)), rdi=3D0x7f6cab91b (garbage)
   #1 memcpy (string_fortified.h:29)
   #2 PooledString::PooledString(str=3D"L 747 Langenstrasse")
      pooled_string.cpp:54  memcpy(tables[tableIndex] + offset, ...)
   #3 PooledString::ensureStringIsOwned() pooled_string.cpp:159
   #4 AttributePair::ensureStringIsOwned() attribute_store.cpp:65
   #5 AttributePairStore::addPair() attribute_store.cpp:181
   #6 AttributeStore::addAttribute(key=3D"name") attribute_store.cpp:247
   #7 OsmLuaProcessing::Attribute() osm_lua_processing.cpp:831
   #8 Lua Attribute() binding (kaguya) osm_lua_processing.cpp:215
   #9.. kaguya invoke, liblua5.4, lua_pcallk
  .
  In the core, tableIndex=3D0 and tables had size 2 =3D=3D capacity 2 (just
  grown by another thread), so the unlocked read of tables[0] hit the
  freed old buffer.
Forwarded: no

--- a/src/pooled_string.cpp
+++ b/src/pooled_string.cpp
@@ -2,9 +2,13 @@
  #include <stdexcept>
  #include <mutex>
  #include <cstring>
+#include <cstdlib>
 =20
  namespace PooledStringNS {
-	std::vector<char*> tables;
+	// Fixed table (never reallocates); lazily committed by the OS.
+	const size_t MaxTables =3D 1 << 24;
+	char** const tables =3D (char**)calloc(MaxTables, sizeof(char*));
+	size_t numTables =3D 0;
  	std::mutex mutex;
 =20
  	const uint8_t ShortString =3D 0b00;
@@ -35,8 +39,10 @@
  			char* buffer =3D (char*)malloc(spaceLeft);
  			if (buffer =3D=3D 0)
  				throw std::runtime_error("PooledString could not malloc");
-			tables.push_back(buffer);
-			tableIndex =3D tables.size() - 1;
+			if (numTables >=3D MaxTables)
+				throw std::runtime_error("PooledString out of tables");
+			tables[numTables] =3D buffer;
+			tableIndex =3D numTables++;
  		}
 =20
  		storage[1] =3D tableIndex >> 16;


Flo
--=20
Florian Lohoff                                                     f@zz.de
   Any sufficiently advanced technology is indistinguishable from magic.

--Ty6EhoN8Js7ptVKO
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEdb9o7oebX2papQ/KkN1BIMsJ8i8FAmr4FaYACgkQkN1BIMsJ
8i/Bdw/8DZNqZs04e71Pn5TtUIVbhyLpf9d+7AwNzShMutqZ9GEl8KKHlPPeo8Qd
b14UFang9ijCAQ4ij0QoFIzNHWql6WSY7zs5fj72XKSVm5qbZDlamFqHE17+x/Gy
C2flFj0AkVnkHvZV7IScSh7C7vysMA/Ay6NrFgy2PUdq9BQPr7J3FD8ZX+VBxO91
q3L3dQTP4oOM3zUkyV1l5bJ2qzCFzXE5eLOw6fTb0hsGOyjI2axFZvRWTy09kP4F
kJLa/GUO6Xj9rOKtc+QdKmM4LSGRZZA/muqdVA/7Xs3thFbcYEcDupb2V8GqCgQo
y1peIZ94wyrpDaUSM7heaHZCwUqSwWE0KZdWrukjpPKy2vJa1Pt1ZAMto0TMel8d
iQ0GxAvNhkYNrdRyT+7AoS930mWxKTJn2tydCmACDWtZWczQ6qRAitZQs2ihM1vM
Am47RjNdEjfc6NCldTux+w0EzDsBaJ8iymJ55D2leT12uenZm4NI8JJJeQXh8D0s
j691WMc9LgD/kMMgFmZSW0RB2uNvopVipb8zivFKvEafoBnPr8VN1J6BGLjm3u1r
i9t55z/O6x0s3XD0aDnoG6wSH3Xvj3jrhh9JHdlJkLfzQO9BnHFciR76amVWbssD
OPSRLDrzZz3/7Sm6srQ0yuHocCjqck0USRWPTdxHF27gxLcEhvk=
=uL/H
-----END PGP SIGNATURE-----

--Ty6EhoN8Js7ptVKO--
Bug#1153953: tilemaker: allocator race crashes in 3.0.0-1 in trixie/stable
#4460
Author: Florian Lohoff
Date: Sat, 14 Nov 2026 09:40
75 lines
4986 bytes
--tG8dWm2CCOyGzaGb
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi Sebastiaan,

On Sat, Nov 14, 2026 at 09:59:49AM +0100, Sebastiaan Couwenberg wrote:
>Control: tags -1 upstream moreinfo
>
>On 11/14/26 9:02 AM, Florian Lohoff via Pkg-grass-devel wrote:
>>First ... thanks for maintaining tilemaker in Debian ..
>
>The package is on life-support since Felix is not as actively involved in =
its maintenance anymore.
>
>>I am running tilemaker in a Debian/Trixie based Docker container i built =
myself every 30 minutes on a pretty small input.
>
>As someone who actually uses the package, would you be willing to=20
>maintain the backport for trixie?

Although i am DD i havent maintained a package in 20? Years :) I faded=20
away when i got Kids - I guess my last Debconf was Helsinki or Oslo.
And the Archs i bootstrapped (mips and mipsel) have meanwhile been=20
removed.

Are you trying to drag me in again? :)=20

>To make your patches eligible for a stable update we'd need to confirm=20
>that the issues are fixed in the version (3.2.0) in testing, but=20
>reproducing race conditions is difficult.
>
>If your issues are fixed in 3.2.0, ideally we'd cherry-pick the=20
>upstream fixes, but it's easier to just rebuild the version in testing=20
>for trixie.

Code has drastically changed in 3.2.0 so i dont think one can easily=20
cherry-pick the upstream fixes.

For the 2nd race i made a pull request upstream but i had to refactor=20
the code as upstream meanwhile most likely also saw crashes and fixed it
differently by using std::deqeue instead of std::vector - which does=20
sort of make it a lot more unlikely but IMHO does not completely fix it.

https://github.com/systemed/tilemaker/pull/992

Flo
--=20
Florian Lohoff                                                     f@zz.de
   Any sufficiently advanced technology is indistinguishable from magic.

--tG8dWm2CCOyGzaGb
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEdb9o7oebX2papQ/KkN1BIMsJ8i8FAmr4J28ACgkQkN1BIMsJ
8i8b0A//YmzhsRyhJDJRW5f19esCIRNi0zaoJpGxZ/ICbPIghcqXA8sVaYaDhuO8
7ZojjT2DxUIa9hi6lZdMlBLAPtNMaOMRR5TpNSQMeQSmCldnNRpLnNe/ftqvllzP
+w7IcpCd3yul7yQTqKDfsH//GEjcTVb4rrCJwxzu7zOoiBspy2bdyXKekfRJRZzZ
HRDuye9tpG8/zvG5PD9bbyO+XBO2hORUPOn/cg5SMoLdUXIfEwxVC6XC+8nJhEu5
mBKa1BwAZlD57tjRpeNaJyYIbi8DWFGsf7A00wCoLl4aFsCAPurtj+RgzuXXaCUu
dCTkhExKKoZYLG8u0VLoOlKsBJ6WUVzQqQ1NjT0rD3DyzFvIIjUsLeesK0dxyNtD
njxbvAHXs4kfnZ8trU1C6JtXeMtKmJaV8PVWl+dXLdv4h/tKTlcG8CSGOA4RnCfy
O0Swr9D633mUgnMJFqIlbJZ+NxG+PlUIdDjs5MzrZpoLyKUsao8uKyNUEnGgrrrf
hnUtgAoJJPyi3HP/8UspCEgH5McFi7/WTxjZBAHst/un7asZroRfFVn7AMmV3HK+
LDjz6e9bOIN4lfmNjZstvwboR4CUc/MfSVZvpLWkGGgxsbWdcTJ9E0hi6KEyWInT
X1cDm0wWOjfLNaChcaY31en7BJ+n7GzLU/BcVu29vMI05k5I9AU=
=g2pQ
-----END PGP SIGNATURE-----

--tG8dWm2CCOyGzaGb--
Bug#1153953: tilemaker: allocator race crashes in 3.0.0-1 in trixie/stable
#4465
Author: Florian Lohoff
Date: Sat, 14 Nov 2026 11:00
69 lines
5008 bytes
--q+EMLAvOxPrVQMSu
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hola,

On Sat, Nov 14, 2026 at 11:19:58AM +0100, Sebastiaan Couwenberg wrote:
>>Are you trying to drag me in again? :)
>
>Yes, we need people involved in maintenance of packages they use=20
>themselves.
>I'm the team's maintainer of last resort, who has increasing difficulty=20
>finding the motivation to work on packages I don't actually use myself.
>It's completely understandable if you want to limit your involvement to=20
>just sharing your patches, you've already gone beyond only fixing the=20
>issue in your local environment.

I know - i still read all the Debian mailinglists and try to keep up=20
with development.

>>https://github.com/systemed/tilemaker/pull/992
>
>What do you want to happen in Debian?

>We could include your patches in a stable update, but I don't want to=20
>take responsibility for that as I don't actually use the package=20
>myself.

I know how difficult it can be to make a stable update but i thought
i at LEAST document the crashes and fixes in the Debian Bug Tracker
for others to find. Sometimes users feel lost about their issues
and finding a bug report which has the same issue, and a possible fix -=20
even if it means to rebuild the package is a lot of help.

I have rebuilt the package with the fixes and put it into my local=20
repository and running my jobs with it for some time.

For "just me" i can do ALL the nasty hacks in packages, doing that
and getting through a Debian quality gate is probably just a nuance
out of my comfort zone - Or - not in the muscle memory anymore.

Flo
--=20
Florian Lohoff                                                     f@zz.de
   Any sufficiently advanced technology is indistinguishable from magic.

--q+EMLAvOxPrVQMSu
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEdb9o7oebX2papQ/KkN1BIMsJ8i8FAmr4PNwACgkQkN1BIMsJ
8i/M5A//Y9mtatlTRfgo1CTqQMExQufqvLSZ+L/PPNiNjz29zhQEK+PSej1grkEo
Ykx6i6A8dDCI1rqoyqkFQR3Tvw72MJrKeJewsIgaEGMqMhHX1XHtbv5DTHllcsBA
ZJhE+Jpd2EPyMPZlt2N4SVUOgxJX/WRliOdKhX0gm0RuhVIxRicyYnu6CnKluPex
uO8ENGoJo6KG/dY8L6g1vkQUNT4hIWSOg/YWMGLCaeJ9ofTIKWmeCznB8fgT+/Q4
laLmXEKgJNreN9T+5pycluoQ4AqJT4Htmoygcjldzk+7EdzqGO/Ysq4oGql/3C08
J0NmKaov1f2VT1kP8z4Y3beMMk4uLCcj2muDW7sAXZGIPedimqnOD/xLRNlaR8yB
yfV0cRGSbG5G2X5tHwPEwtLOtzpQLADpImMw+/i6fTgTBND4UeMwxn5TAWLHbBuN
7b8wX3dEVQKmY+xVS4vsghCkaPZuUJvTSCzi/B/cwd++KZt6Dyjw9/sY1MHXbrvY
VGRn+aHqlWHzmWj0tIKh9jfLt+Ravh2uG5icLL4pfTfJjWDoGt2WlgAmQxBAHTSz
tk8G9OgJoffSsTyFfv4QFzjo+l1X6lpoysFOJSkjivC2Lm/Qo/0DtiQgX9NNkf6P
REchOIFeby5uki/jI41g8xBWlcNBwxBOmPmpMk4X4Rm3sFs/dXU=
=bkie
-----END PGP SIGNATURE-----

--q+EMLAvOxPrVQMSu--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads