h3-pg
h3-pg copied to clipboard
h3_line fails with invalid memory alloc request size error
00:23:10 [gis] > select h3_line('88bad9c195fffff', '887fa67635fffff');
ERROR: XX000: invalid memory alloc request size 18446744073709551608
LOCATION: palloc, mcxt.c:1078
Time: 1,489 ms
I tried to investigate this problem myself and found out that h3LineSize (https://github.com/bytesandbrains/h3-pg/blob/bf6198b346946ef399498bd532e17438db4bac77/h3/src/lib/traversal.c#L204) returns -1 for my input. Looks like assert that positive size is returned by h3LineSize need to be added.
I also took a look at h3's that cause this error and seems like one of them crosses 180th meridian.
00:40:50 [gis] > select h3_to_geo('88bad9c195fffff');
┌────────────────────────────────────────┐
│ h3_to_geo │
├────────────────────────────────────────┤
│ (179.9969603999748,-22.92832332131207) │
└────────────────────────────────────────┘
(1 row)
Time: 2,285 ms
Thanks, good catch! We definitely need an assert there.
This will be covered when v4 is released. Thanks!