#4994 closed defect (fixed)
shp2pgsql is sometimes missing the INSERT statements
Reported by: | myon | Owned by: | robe |
---|---|---|---|
Priority: | blocker | Milestone: | PostGIS 3.1.5 |
Component: | utils/loader-dumper | Version: | 2.5.x -- EOL |
Keywords: | Cc: | Bas Couwenberg, pramsey |
Description
I've been chasing regression tests failures seen in 3.2 on Debian unstable: https://pgdgbuild.dus.dg-i.net/view/Binaries/job/postgis-binaries/326/architecture=amd64,distribution=sid/console The sympton is always that the diff shows some rows missing.
I managed to track it down to shp2pgsql sometimes missing the INSERT part; running it in a loop will eventually trigger the bug.
while ./loader/shp2pgsql -G -g the_geom ./regress/loader/MultiPointZ.shp loadedshp | grep INSERT; do :; done ... Shapefile type: MultiPointZ Postgis type: MULTIPOINT[4] INSERT INTO "loadedshp" (the_geom) VALUES ('01040000E0E61000000300000001010000C00000000000000000000000000000F03F0000000000000040000000000000084001010000C00000000000002240000000000000F0BF00000000000000C000000000000008C001010000C00000000000002240000000000000F0BF00000000000034C00000000000C05EC0'); Shapefile type: MultiPointZ Postgis type: MULTIPOINT[4] INSERT INTO "loadedshp" (the_geom) VALUES ('01040000E0E61000000300000001010000C00000000000000000000000000000F03F0000000000000040000000000000084001010000C00000000000002240000000000000F0BF00000000000000C000000000000008C001010000C00000000000002240000000000000F0BF00000000000034C00000000000C05EC0'); Shapefile type: MultiPointZ Postgis type: MULTIPOINT[4] <-- no INSERT here
Change History (17)
comment:1 by , 3 years ago
Component: | postgis → loader/dumper |
---|---|
Milestone: | PostGIS 3.1.5 → PostGIS 3.2.0 |
Owner: | changed from | to
Version: | 2.5.x → master |
comment:2 by , 3 years ago
Milestone: | PostGIS 3.2.0 → PostGIS 3.1.5 |
---|
comment:3 by , 3 years ago
Component: | loader/dumper → postgis |
---|---|
Owner: | changed from | to
Version: | master → 2.5.x |
Thanks robe2 and strk on #postgis for their patience. More datapoints:
15 22:06 <Myon> oookay, I can trigger the bug using shp2pgsql from 3.1.4+dfsg-1.pgdg+1 on unstable 15 22:07 <Myon> but not using 3.1.3+dfsg-1~exp1.pgdg+1+b1 on (a semi-up-to-date) bookworm 15 22:13 <Myon> 3.1.1+dfsg-1 on bullseye seems ok 15 22:14 <Myon> 3.1.4+dfsg-1.pgdg110+1 on bullseye seems ok 15 22:18 <Myon> 3.1.4+dfsg-1.pgdg+1 on bookworm seems ok 15 22:19 <Myon> 3.2.0~alpha1+dfsg-1~exp1 from experimental installed on bookworm is also ok 15 22:19 <Myon> so it seems it might be an issue with the OS or some library on unstable 15 22:19 <Myon> ... that hasn't trickled down to testing/bookworm yet
comment:4 by , 3 years ago
Component: | postgis → loader/dumper |
---|---|
Owner: | changed from | to
comment:6 by , 3 years ago
Cc: | added |
---|
comment:7 by , 3 years ago
I can reproduce on sid chroot. Valgrind says:
==38338== Conditional jump or move depends on uninitialised value(s) ==38338== at 0x1175B6: ShpLoaderGenerateSQLRowStatement (shp2pgsql-core.c:1564) ==38338== by 0x10BDF5: main (shp2pgsql-cli.c:397)
comment:8 by , 3 years ago
So if my reading is correct, the INSERT is missing when the uninitialized memory contains bits that make shp2pgsql think the record was deleted.
comment:10 by , 3 years ago
Still present, the valgrind reported error, on 64bit and with reduced switches:
$ valgrind ./loader/shp2pgsql ./regress/loader/PointZ.shp ... Shapefile type: PointZ Postgis type: POINT[4] ==49529== Conditional jump or move depends on uninitialised value(s) ==49529== at 0x119ED1: ShpLoaderGenerateSQLRowStatement (shp2pgsql-core.c:1564) ==49529== by 0x10E6A8: main (shp2pgsql-cli.c:397) ...
comment:11 by , 3 years ago
It looks like updating dbfopen.c to current master branch of https://github.com/OSGeo/shapelib fixes the issue.
comment:12 by , 3 years ago
Cc: | added |
---|
Actually I'm wrong: using the latest dbfopen.c does fix the valgrind error but results in no records being used.
Rerting commit [595f840ebc479657adac9143cfaf890faba72f99/git] instead fixes the valgrind reported error while still passing testsuite. Paul: that commit was yours
Note that when reverting the above commit we get on stderr this printed: fread(1) failed on DBF file
comment:13 by , 3 years ago
Priority: | medium → blocker |
---|
Paul: reverting commit [595f840ebc479657adac9143cfaf890faba72f99/git] still passes testsuite, do you remember HOW you could trigger the misbehaviour which made you push that change ? Is it not in the testsuite ?
comment:16 by , 3 years ago
Fwiw this needs backporting, the problem is at least also visible using shp2pgsql from 3.1.4+dfsg-1.pgdg+1 on Debian unstable.
Myon noted he can trigger in 3.1.4 but not 3.1.3
Note from IRC:
So this could be a debian unstable issue though strk recalls being able to trigger these things -- but we know strk doesn't ever run bleeding edge OS.