You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered that when using the cellsToMultiPolygon method, a SIGSEGV error can occur if there are duplicate indices in the input array. And this issue was addressed in a recent bug fix.
However, since the cellsToLinkedMultiPolygon method is designed to take a set as input, i think it would be beneficial to add a pre-processing step to ensure the input array has unique elements before calling h3Api.cellsToLinkedMultiPolygon.
Alternatively, there should be at least a comment in the code indicating that the input array must contain unique elements. Additionally, it would be helpful to specify an error code for the H3Exception, as it currently returns only 1.
It was really hard for me to find out the reason for the error 😭
Changing the signature of cellsToMultiPolygon(Collection<Long> h3, boolean geoJson) to cellsToMultiPolygon(Set<Long> h3, boolean geoJson) will enforce it to not have duplicates, as per definition a set doesn't contain duplicates, and not further change is required in the H3Core to deduplicate anything.
I've looked into this and implemented the fix suggested by @luneo7.
I updated the cellsToMultiPolygon and cellAddressesToMultiPolygon methods in H3Core to require a Set instead of a Collection. This enforces uniqueness at the API level and prevents duplicate inputs from reaching the native C library, avoiding the SIGSEGV crash.
I also updated the H3CoreV3 backward-compatibility layer to safely wrap legacy inputs, and updated the test suite to compile against the stricter API.
I have opened PR #208 with these changes. Let me know if any further adjustments are needed!
Activity
luneo7 commentedon Nov 12, 2024
Changing the signature of
cellsToMultiPolygon(Collection<Long> h3, boolean geoJson)tocellsToMultiPolygon(Set<Long> h3, boolean geoJson)will enforce it to not have duplicates, as per definition a set doesn't contain duplicates, and not further change is required in the H3Core to deduplicate anything.dyrpsf commentedon Jun 20, 2026
Hi @luneo7 and @seajung,
I've looked into this and implemented the fix suggested by @luneo7.
I updated the
cellsToMultiPolygonandcellAddressesToMultiPolygonmethods inH3Coreto require aSetinstead of aCollection. This enforces uniqueness at the API level and prevents duplicate inputs from reaching the native C library, avoiding theSIGSEGVcrash.I also updated the
H3CoreV3backward-compatibility layer to safely wrap legacy inputs, and updated the test suite to compile against the stricter API.I have opened PR #208 with these changes. Let me know if any further adjustments are needed!