pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
6+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 01:34 "SamuelMarks (@SamuelMarks)" <noreply+SamuelMarks@github.com>
0 siblings, 0 replies; 6+ messages in thread
From: SamuelMarks (@SamuelMarks) @ 2024-08-23 01:34 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
```
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnswutils.o src/hnswutils.c
In file included from /usr/local/include/postgresql/server/c.h:61,
from /usr/local/include/postgresql/server/postgres.h:45,
from src/hnswutils.c:1:
In function 'memcpy',
inlined from 'HnswSearchLayer' at src/hnswutils.c:786:4:
/usr/include/fortify/string.h:51:31: warning: 'neighborhoodSize' may be used uninitialized [-Wmaybe-uninitialized]
51 | (__s < __d && __s + __n > __d))
| ~~~~^~~~~
src/hnswutils.c: In function 'HnswSearchLayer':
src/hnswutils.c:733:25: note: 'neighborhoodSize' was declared here
733 | Size neighborhoodSize;
| ^~~~~~~~~~~~~~~~
```
inline patch 1: src/hnswutils.c (+1/-1 lines) download inline-1.patch
diff --git a/src/hnswutils.c b/src/hnswutils.c
index f7ce99a65..96c50263a 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -730,7 +730,7 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
visited_hash v;
ListCell *lc2;
HnswNeighborArray *neighborhoodData = NULL;
- Size neighborhoodSize;
+ Size neighborhoodSize = 0;
InitVisited(base, &v, index, ef, m);
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 01:59 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-08-23 01:59 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @SamuelMarks, I'm not sure how to reproduce the warning. What compiler are you using (`gcc --version`), and how was Postgres installed?
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 02:24 "SamuelMarks (@SamuelMarks)" <noreply+SamuelMarks@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: SamuelMarks (@SamuelMarks) @ 2024-08-23 02:24 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Here's a simple Dockerfile
```dockerfile
ARG PG_MAJOR=16
FROM postgres:${PG_MAJOR}-alpine AS builder
ARG PG_MAJOR
ARG PG_VECTOR="0.7.4"
WORKDIR /tmp/pgvector
ADD "https://github.com/pgvector/pgvector/archive/refs/tags/v${PG_VECTOR}.tar.gz" .
RUN tar xf "v${PG_VECTOR}.tar.gz" && \
apk add --no-cache build-base clang15 llvm15 postgresql${PG_MAJOR}-dev && \
cd /tmp/pgvector/pgvector-${PG_VECTOR} && \
make clean && \
make OPTFLAGS=""
```
`docker build` output until the point of replication:
```
$ docker build --progress=plain . -t tmp
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 444B done
#1 DONE 0.2s
#2 [internal] load metadata for docker.io/library/postgres:16-alpine
#2 DONE 0.0s
#3 [internal] load .dockerignore
#3 transferring context:
#3 transferring context: 2B done
#3 DONE 0.1s
#4 [1/4] FROM docker.io/library/postgres:16-alpine
#4 CACHED
#5 [2/4] WORKDIR /tmp/pgvector
#5 DONE 0.2s
#6 [3/4] ADD https://github.com/pgvector/pgvector/archive/refs/tags/v0.7.4.tar.gz .
#6 DONE 0.5s
#6 [3/4] ADD https://github.com/pgvector/pgvector/archive/refs/tags/v0.7.4.tar.gz .
#6 CACHED
#7 [3/4] ADD https://github.com/pgvector/pgvector/archive/refs/tags/v0.7.4.tar.gz .
#7 DONE 0.3s
#8 [4/4] RUN tar xf "v0.7.4.tar.gz" && apk add --no-cache build-base clang15 llvm15 postgresql16-dev && cd /tmp/pgvector/pgvector-0.7.4 && make clean && make OPTFLAGS=""
#8 0.411 fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
#8 0.958 fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
#8 1.428 (1/40) Installing jansson (2.14-r4)
#8 1.447 (2/40) Installing binutils (2.42-r0)
#8 1.781 (3/40) Installing libmagic (5.45-r1)
#8 1.838 (4/40) Installing file (5.45-r1)
#8 1.852 (5/40) Installing libgomp (13.2.1_git20240309-r0)
#8 1.887 (6/40) Installing libatomic (13.2.1_git20240309-r0)
#8 1.964 (7/40) Installing gmp (6.3.0-r1)
#8 2.004 (8/40) Installing isl26 (0.26-r1)
#8 2.101 (9/40) Installing mpfr4 (4.2.1-r0)
#8 2.161 (10/40) Installing mpc1 (1.3.1-r1)
#8 2.191 (11/40) Installing gcc (13.2.1_git20240309-r0)
#8 6.516 (12/40) Installing libstdc++-dev (13.2.1_git20240309-r0)
#8 6.838 (13/40) Installing musl-dev (1.2.5-r0)
#8 7.170 (14/40) Installing g++ (13.2.1_git20240309-r0)
#8 8.350 (15/40) Installing make (4.4.1-r2)
#8 8.378 (16/40) Installing fortify-headers (1.1-r3)
#8 8.399 (17/40) Installing patch (2.7.6-r10)
#8 8.420 (18/40) Installing build-base (0.5-r3)
#8 8.435 (19/40) Installing clang15-headers (15.0.7-r19)
#8 8.529 (20/40) Installing clang15-libs (15.0.7-r19)
#8 10.48 (21/40) Installing clang15-libclang (15.0.7-r19)
#8 11.61 (22/40) Installing clang15 (15.0.7-r19)
#8 12.81 (23/40) Installing llvm15 (15.0.7-r13)
#8 15.26 (24/40) Installing libpq (16.3-r0)
#8 15.30 (25/40) Installing pkgconf (2.2.0-r0)
#8 15.33 (26/40) Installing openssl-dev (3.3.1-r3)
#8 15.39 (27/40) Installing libpq-dev (16.3-r0)
#8 15.45 (28/40) Installing libecpg (16.3-r0)
#8 15.48 (29/40) Installing libecpg-dev (16.3-r0)
#8 15.53 (30/40) Installing clang16-headers (16.0.6-r5)
#8 15.65 (31/40) Installing llvm16-libs (16.0.6-r8)
#8 19.90 (32/40) Installing clang16-libs (16.0.6-r5)
#8 22.14 (33/40) Installing llvm16-linker-tools (16.0.6-r8)
#8 22.17 (34/40) Installing clang16 (16.0.6-r5)
#8 22.21 (35/40) Installing icu (74.2-r0)
#8 22.26 (36/40) Installing icu-dev (74.2-r0)
#8 22.40 (37/40) Installing llvm16 (16.0.6-r8)
#8 26.47 (38/40) Installing lz4-dev (1.9.4-r5)
#8 26.49 (39/40) Installing zstd-dev (1.5.6-r0)
#8 26.52 (40/40) Installing postgresql16-dev (16.3-r0)
#8 26.74 Executing busybox-1.36.1-r29.trigger
#8 26.75 OK: 942 MiB in 85 packages
#8 26.84 rm -f vector.so libvector.a libvector.pc
#8 26.84 rm -f sql/vector--0.7.4.sql
#8 26.84 rm -f src/bitutils.o src/bitvec.o src/halfutils.o src/halfvec.o src/hnsw.o src/hnswbuild.o src/hnswinsert.o src/hnswscan.o src/hnswutils.o src/hnswvacuum.o src/ivfbuild.o src/ivfflat.o src/ivfinsert.o src/ivfkmeans.o src/ivfscan.o src/ivfutils.o src/ivfvacuum.o src/sparsevec.o src/vector.o src/bitutils.bc src/bitvec.bc src/halfutils.bc src/halfvec.bc src/hnsw.bc src/hnswbuild.bc src/hnswinsert.bc src/hnswscan.bc src/hnswutils.bc src/hnswvacuum.bc src/ivfbuild.bc src/ivfflat.bc src/ivfinsert.bc src/ivfkmeans.bc src/ivfscan.bc src/ivfutils.bc src/ivfvacuum.bc src/sparsevec.bc src/vector.bc
#8 26.84 rm -rf results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
#8 26.86 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/bitutils.o src/bitutils.c
#8 27.22 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/bitvec.o src/bitvec.c
#8 27.27 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/halfutils.o src/halfutils.c
#8 27.74 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/halfvec.o src/halfvec.c
#8 28.33 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnsw.o src/hnsw.c
#8 28.44 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnswbuild.o src/hnswbuild.c
#8 28.71 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnswinsert.o src/hnswinsert.c
#8 28.91 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnswscan.o src/hnswscan.c
#8 29.02 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/hnswutils.o src/hnswutils.c
#8 29.64 In file included from /usr/local/include/postgresql/server/c.h:61,
#8 29.64 from /usr/local/include/postgresql/server/postgres.h:45,
#8 29.64 from src/hnswutils.c:1:
#8 29.64 In function 'memcpy',
#8 29.64 inlined from 'HnswSearchLayer' at src/hnswutils.c:786:4:
#8 29.64 /usr/include/fortify/string.h:51:31: warning: 'neighborhoodSize' may be used uninitialized [-Wmaybe-uninitialized]
#8 29.64 51 | (__s < __d && __s + __n > __d))
#8 29.64 | ~~~~^~~~~
#8 29.64 src/hnswutils.c: In function 'HnswSearchLayer':
#8 29.64 src/hnswutils.c:733:25: note: 'neighborhoodSize' was declared here
#8 29.64 733 | Size neighborhoodSize;
#8 29.64 | ^~~~~~~~~~~~~~~~
```
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 02:51 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-08-23 02:51 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 02:51 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-08-23 02:51 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane merged this (commit 4cede1a9c9a8).
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized`
@ 2024-08-23 02:51 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-08-23 02:51 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Great, thanks!
^ permalink raw [nested|flat] 6+ messages in thread
end of thread, other threads:[~2024-08-23 02:51 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-23 01:34 [pgvector/pgvector] PR #654: [src/hnswutils.c] Resolve 1 `-Wmaybe-uninitialized` "SamuelMarks (@SamuelMarks)" <noreply+SamuelMarks@github.com>
2024-08-23 01:59 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-08-23 02:24 ` "SamuelMarks (@SamuelMarks)" <noreply+SamuelMarks@github.com>
2024-08-23 02:51 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-08-23 02:51 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-08-23 02:51 ` "ankane (@ankane)" <noreply+ankane@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox