h3-pg icon indicating copy to clipboard operation
h3-pg copied to clipboard

h3_line fails with invalid memory alloc request size error

Open kalenikaliaksandr opened this issue 3 years ago • 1 comments

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

kalenikaliaksandr avatar May 18 '22 21:05 kalenikaliaksandr

Thanks, good catch! We definitely need an assert there.

zachasme avatar May 23 '22 09:05 zachasme

This will be covered when v4 is released. Thanks!

zachasme avatar Aug 23 '22 11:08 zachasme