Closed oobayly closed 2 months ago
D'oh, sorry that you're hitting this. I can offer some context.
In https://github.com/systemed/tilemaker/pull/583/, I changed AttributePair
to identify the key by a short
rather than a std::string
. This had the effect of limiting us to 64K unique keys, which is probably plenty.
In https://github.com/systemed/tilemaker/pull/618, I further changed it to use at most 9 bits: https://github.com/systemed/tilemaker/blob/eab08d189ad97ddf5db7d915bcabe42ad3dab6af/include/attribute_store.h#L49
That limits us to at most 512 unique keys.
Except... this has the same bug as https://github.com/systemed/tilemaker/pull/672 did: it's using a signed type. Instead of short : 9
, it should be unsigned short : 9
. As it stands, the usable range is -256..255
, not 0..511
, so you can actually only squeeze in 256 keys before hitting issues.
So probably there are at least two things that ought to be done:
unsigned short : 9
so we get the full range.AttributeKeyStore
assert if it would return an index that would be out-of-bounds (so that future people who hit this issue get a useful error, not a segfault)And then possibly:
AttributePair
. Maybe in your scenario that's not needed?@cldellow Nice. My first thought was that it was an overflow, given the unexpected number, but the bounds (-245) just didn't make sense to me. Too big for 8 bit, too small for 16 bit. The daft part is that when looking at the definition short keyIndex : 9;
I did wonder about the syntax (I'm not a C/C++ guy, should have googled it though).
Just to verify this...
branch
, which means the tag key will be usage
and the keyIndex = -245maxspeed
with a index of -244Feeling pretty daft that I didn't work that one out 🤦
So, with regards to this:
Great, thanks for verifying the issue! I opened #760 to apply that fix + improve the failure mode. I've left the limit at 512 - if/when someone complains that it's not enough, we can revisit improving it.
I came across this when adding a large number of attributes to a nodes. In my case I was adding all the OSM tags with a
railway:
prefix (I'm not planning on doing always doing this, but it's useful for development). This was fine for a small region (Köln Rebenz), but would end with SIGSEGV when using the parent area (Nordrehin Westfalen).My first thought was that it's an OOM error, but this turned out not to be the case:
--store
flag, but this made no difference.railways:
tags did work, with a similar 3.5GB usage.So, it seems to be an issue with attributes, I:
AttributeStore->keyStore
. I appreciate that this many not be great practice, but nor should this be causing a SegFault.In short, it was
error reading variable: Cannot access memory at address 0x1a149fe
, and was been thrown in OutputObject::writeAttributes:49Attaching a debugger, I found that address of the string
const std::string& key = attributeStore.keyStore.getKeyUnsafe(it->keyIndex);
was invalid, and attempting to read it is causing an access violation. More specifically, the iteratorit
had an invalid (negative)keyIndex
value. What's interesting is that the other properties for theAttributePair
is valid,valueType
and the string instringValue
.I'll try setting up a simple (but completely unrealistic) set up so it can be reproduced on demand.
As an aside, I'm going to create another 2 issues with associated PR that helped me with getting live debugging to work via docker.
751
752