[Tile-serving] [osm2pgsql-dev/osm2pgsql] Segfault happening (Issue #2265)
Jochen Topf
notifications at github.com
Thu Dec 12 16:41:32 UTC 2024
I believe I have figured out what is happening here: There are several threads in the thread pool. Thread A is started and opens a database connection and all is fine so far. Then thread B is started and doesn't get a database connection any more, it throws an exception. The exception is propagated and as part of that propagation lots of things are destructed. At some point the data structure containing the information about tables is destructed. Now thread A gets a chance to run again and wants to build the `CREATE INDEX` command. It needs the information about the tables, but that was destructed already. And then it segfaults.
To solve this we would need to make sure all threads are destructed *before* anything else. But there is no way to kill a running std::thread. We would have to wait until it is done with its work, which doesn't make much sense, because that situation isn't recoverable anyway. In C++20 there is a new `std::jthread` which has some mechanism for stopping it from the outside, but I believe that also only works if the thread cooperates. But if that thread just called `CREATE INDEX` it might be a long time before it even gets to run and can notice that it should shutdown.
At the moment, I don't have a good idea how to solve this. :-(
--
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/issues/2265#issuecomment-2539463603
You are receiving this because you are subscribed to this thread.
Message ID: <osm2pgsql-dev/osm2pgsql/issues/2265/2539463603 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20241212/a573f3d5/attachment.htm>
More information about the Tile-serving
mailing list