Skip to content

CharsToNameCanonicalizer: Internal error on SymbolTable.rehash() with high number of hash collisions #547

@alpire

Description

@alpire

Fuzzing jackson-core led to the following exception during CharsToNameCanonicalizer's rehashing:

java.lang.IllegalStateException: Internal error on SymbolTable.rehash(): had 3379 entries; now have 3381
       at com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.rehash(CharsToNameCanonicalizer.java:678)
       at com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer._addSymbol(CharsToNameCanonicalizer.java:483)
       at com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.findSymbol(CharsToNameCanonicalizer.java:463)
       at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1813)
       at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:932)
       at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:295)
       at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
       at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4086)
       at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3139))

Rehasing leads to additional entries in the hash table. This is probably due from _size not maching the actual number of entries in the hash table. I unfortunately cannot easily reproduce the issue since it is the results of parsing millions of inputs in the same process. Starting another fuzzing run may or may not trigger it.

Looking at the code, I think this mismatch could be stemming from _handleSpillOverflow. The function reduces the _size by newBucket.length, even though it keeps one item out of that bucket in the table. I believe that line should be _size -= (newBucket.length - 1);. The code is unfamiliar to me, so it's very possibly I got that wrong.

jackson-core was compiled from source (commit c8fe42d in 2.10). jackson-bind and jackson-annotations were downloaded from maven (2.10.0.pr1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions