Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning and note in sqlite3-binding.c #803

Closed
KrisCarr opened this issue Apr 14, 2020 · 21 comments
Closed

Warning and note in sqlite3-binding.c #803

KrisCarr opened this issue Apr 14, 2020 · 21 comments

Comments

@KrisCarr
Copy link

Every time my application starts or tests are run I get the following in my output:

# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 |   Select standin;
       |          ^~~~~~~

I can get round this by adding -w to the CFLAGS option inside sqlite3.go

Is there a better way to get rid of this warning and note?

I am running on Fedora 32 x86_64

@KrisCarr
Copy link
Author

I have added -Wno-return-local-addr" to my environment variables in .bashrc which has got rid of all that mess for the time being.

export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

@james-d-elliott
Copy link

james-d-elliott commented May 7, 2020

A user of a product I am one of the maintainers for complained about the same thing. If you're able I'm interested in your gcc, glibc, and libsqlite3 versions; as it works fine for me.

For ref my versions are 9.3, 2.31, and 3.31.1

@pgnd
Copy link

pgnd commented May 8, 2020

with

sqlite3 --version
	3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt1

build with gcc10

	echo $CC $CXX $CPP
		/usr/bin/gcc-10 /usr/bin/g++-10 /usr/bin/cpp-10
	$CC --version
		gcc-10 (SUSE Linux) 10.1.1 20200507 [revision dd38686d9c810cecbaa80bb82ed91caaa58ad635]
	go build github.com/mattn/go-sqlite3
		# github.com/mattn/go-sqlite3
		sqlite3-binding.c: In function ‘sqlite3SelectNew’:
		sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
		128049 |   return pNew;
		       |          ^~~~
		sqlite3-binding.c:128009:10: note: declared here
		128009 |   Select standin;
		       |          ^~~~~~~

and, build with gcc9

	echo $CC $CXX $CPP
		/usr/bin/gcc-9 /usr/bin/g++-9 /usr/bin/cpp-9
	$CC --version
		gcc-9 (SUSE Linux) 9.3.1 20200406 [revision 6db837a5288ee3ca5ec504fbd5a765817e556ac2]
	go build github.com/mattn/go-sqlite3

=====> NO SQLITE3 ERROR <====

@james-d-elliott
Copy link

james-d-elliott commented May 8, 2020

Yeah, looks like a gcc 10 issue, 9.3 works fine. It's likely the issue lies with libsqlite3-0 3.31.1 and gcc 10.x. Either a new warning being detected or a problem with 10.x - a lot of issues were resolved in 10.1 marked as regressions introduced between 9.3 and 10.0 (~700) so it could be that.

@pgnd
Copy link

pgnd commented May 8, 2020

looks likely

git clone https://github.com/sqlite/sqlite.git
cd sqlite
git checkout version-3.31.1
gcc --version
	gcc (SUSE Linux) 10.1.1 20200507 [revision dd38686d9c810cecbaa80bb82ed91caaa58ad635]
./configure
make
	...
	libtool: link: /usr/bin/gcc-10 -O3 -Wall -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -D_FORTIFY_SOURCE=2 -O3 -Wall -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -DSQLITE_OS_UNIX=1 -I. -I/usr/local/src/sqlite/src -I/usr/local/src/sqlite/ext/rtree -I/usr/local/src/sqlite/ext/icu -I/usr/local/src/sqlite/ext/fts3 -I/usr/local/src/sqlite/ext/async -I/usr/local/src/sqlite/ext/session -I/usr/local/src/sqlite/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -DSQLITE_THREADSAFE=1 -DSQLITE_HAVE_ZLIB=1 -DHAVE_READLINE=0 -DHAVE_EDITLINE=1 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_DESERIALIZE -o sqlite3 shell.c sqlite3.c  -ledit -ldl -lz -lpthread -Wl,-rpath -Wl,/usr/local/sqlite-gcc10-test/lib64
	In function 'zipfileComparePath',
	    inlined from 'zipfileUpdate' at shell.c:5784:11:
	shell.c:5656:17: warning: '__builtin_memcmp_eq' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
	 5656 |   if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
	      |                 ^~~~~~~~~~~~~~~~~~
	sqlite3.c: In function ‘sqlite3SelectNew’:
	sqlite3.c:128048:10: warning: function may return address of local variable [-Wreturn-local-addr]
	128048 |   return pNew;
	       |          ^~~~
	sqlite3.c:128008:10: note: declared here
	128008 |   Select standin;
	       |          ^~~~~~~
	sqlite3.c:128008:10: note: declared here
	sqlite3.c: In function 'sqlite3SelectNew':
	sqlite3.c:128048:10: warning: function may return address of local variable [-Wreturn-local-addr]
	128048 |   return pNew;
	       |          ^~~~
	sqlite3.c:128008:10: note: declared here
	128008 |   Select standin;
	       |          ^~~~~~~
	sqlite3.c:128008:10: note: declared here
	...

@rbucker
Copy link

rbucker commented May 15, 2020

In my case...

$ go get -u -v github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 |   Select standin;
       |          ^~~~~~~

ClearLinux version:

$ swupd check-update 
Current OS version: 33100
Latest server version: 33100
There are no updates available

GCC Version

$ gcc --version
gcc (Clear Linux OS for Intel Architecture) 10.1.1 20200513 releases/gcc-10.1.0-36-gf2b77b928a
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@ghost
Copy link

ghost commented May 18, 2020

windows 10 x64 2004 has the same issue

@james-d-elliott
Copy link

This is an upstream bug with libsqlite3, not sure where their bug tracker is.

@subpop
Copy link

subpop commented May 18, 2020

This is an upstream bug with libsqlite3, not sure where their bug tracker is.

https://www3.sqlite.org/cgi/src/ticket

@LawnGnome
Copy link

There's a discussion on the SQLite Forum about this issue, including a candidate patch.

@payloadartist
Copy link

payloadartist commented Mar 3, 2021

Facing this issue with GoORM, which uses this sqlite3 driver. Any workarounds?

Update - adding this env variable fixed it, export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

@edo1
Copy link

edo1 commented Apr 29, 2021

fixed in sqlite3 release 3.33, so go-sqlite3 1.14.1 and later doesn't have this issue

P. S. actual go-sqlite3 release is 1.14.7, not 2.0.x

@qweccc
Copy link

qweccc commented May 6, 2021

export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

itz work

@awfulcooking
Copy link

Don't disable these warnings, people. You want to see them.

It's like seeing a small fire, closing your eyes and pretending it's not there!

@pablodz
Copy link

pablodz commented Feb 7, 2022

Don't disable these warnings, people. You want to see them.

It's like seeing a small fire, closing your eyes and pretending it's not there!

You have described the whole tech industry

image

@ghost
Copy link

ghost commented Aug 11, 2022

Hello I am facing the same problem while I try to install gophish.
I use sudo go install github.com/gophish/gophish@latest ( Because get is deprecated from go dependecies and should add the value @latest or version.

github.com/mattn/go-sqlite3

sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 | return pNew;
| ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 | Select standin;
| ^~~~~~~
This is the error I get. Please is there any workaround?

@rittneje
Copy link
Collaborator

@shalota1 gophish is using v2.0.3 of this library, which is quite old. You will need to ask the maintainer to upgrade to the latest version (v1.14.14) and try that.

@PetengDedet
Copy link

For Windows user

go env -w CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

@mvikrammenon
Copy link

mvikrammenon commented Apr 26, 2023

@shalota1 gophish is using v2.0.3 of this library, which is quite old. You will need to ask the maintainer to upgrade to the latest version (v1.14.14) and try that.

Thanks for pointing it out. Tried go get github.com/mattn/go-sqlite3@v1.14.16 and that updated few dependencies. Able to build successfully in my Amazon Linux box.
Have raised a PR with fix. gophish/gophish#2848

@rytcnt
Copy link

rytcnt commented May 10, 2023

@shalota1 gophish is using v2.0.3 of this library, which is quite old. You will need to ask the maintainer to upgrade to the latest version (v1.14.14) and try that.

Thanks for pointing it out. Tried go get github.com/mattn/go-sqlite3@v1.14.16 and that updated few dependencies. Able to build successfully in my Amazon Linux box. Have raised a PR with fix. gophish/gophish#2848

Thanks - I was able to use your proposed fixes to the go.mod and go.sum files, after doing a git clone https://github.com/gophish/gophish.git then a go build in the directory once the two files were modified. For some reason the go get command didn't work, nor did the go install commands.

zeldovich added a commit to zeldovich/go-algorand that referenced this issue Aug 8, 2023
The version of go-sqlite3 we are currently using (v1.10.0) generates
a warning from the C compiler on many go commands (like go build,
go test, go vet, etc):

    # github.com/mattn/go-sqlite3
    sqlite3-binding.c: In function ‘sqlite3SelectNew’:
    sqlite3-binding.c:123303:10: warning: function may return address of local variable [-Wreturn-local-addr]
    123303 |   return pNew;
           |          ^~~~
    sqlite3-binding.c:123263:10: note: declared here
    123263 |   Select standin;
           |          ^~~~~~~

This change updates go-sqlite3 to the latest version (v1.14.16), which
was fixed to avoid this warning; see:

    mattn/go-sqlite3#803
    https://sqlite.org/forum/forumpost/e39020f82d7d510ea4d4a08ae370ca8df061c8b91884c82fda4897853faa2096
mhilton added a commit to influxdata/flux that referenced this issue Nov 21, 2023
Update the go-sqlite3 module to receive that fix for
mattn/go-sqlite3#803 which has started
occuring since the build machinary was updated.
mhilton added a commit to influxdata/flux that referenced this issue Nov 21, 2023
* chore(deps): update github.com/mattn/go-sqlite3

Update the go-sqlite3 module to receive that fix for
mattn/go-sqlite3#803 which has started
occuring since the build machinary was updated.

* fix: lint

* chore: update staticcheck to support newer go versions

* fix: staticcheck

* fix: go error formatting

* chore: increase benchmark timeout
dude333 added a commit to dude333/rapina that referenced this issue Feb 20, 2024
@rittneje
Copy link
Collaborator

rittneje commented Mar 3, 2024

Closing because I believe this issue has long since been fixed in SQLite itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests