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

[compilation error] aead.c:220:43: error: passing argument 9 of ‘crypto_aead_aes256gcm_decrypt_afternm’ from incompatible pointer type #2179

Closed
fsgmhoward opened this issue Sep 12, 2018 · 10 comments
Labels

Comments

@fsgmhoward
Copy link

fsgmhoward commented Sep 12, 2018

What version of shadowsocks-libev are you using?

Latest commit (3.2.0-44-ga7877c5)

What operating system are you using?

Ubuntu Trusty/Precise (Xenial/Bionic don't have such a problem, using libsodium of the same version (1.0.16-119-g04a7ab9 for amd64/arm64/ppc64el, 1.0.16-116-g9c86285 for armhf/i386))

What did you do?

Build deb package from the source through Launchpad.net

What did you expect to see?

Successful build

What did you see instead?

Build failure for all architecture of Trusty & Precise.
(see https://launchpad.net/~fsgmhoward/+archive/ubuntu/shadowsocks-libev/+packages, full log can be downloaded here as well).

libshadowsocks_libev_la-aead.lo `test -f 'aead.c' || echo './'`aead.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE -pthread -I../libbloom -I../libipset/include -I../libcork/include -DMODULE_LOCAL -DLIB_ONLY -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread -c aead.c  -fPIC -DPIC -o .libs/libshadowsocks_libev_la-aead.o
aead.c: In function ‘aead_cipher_encrypt’:
aead.c:172:43: error: passing argument 9 of ‘crypto_aead_aes256gcm_encrypt_afternm’ from incompatible pointer type [-Werror]
                                           ad, adlen, NULL, n, cipher_ctx->aes256gcm_ctx);
                                           ^
In file included from /usr/include/sodium.h:8:0,
                 from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:118:5: note: expected ‘const unsigned char (*)[512]’ but argument is of type ‘unsigned char (*)[512]’
 int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
     ^
aead.c: In function ‘aead_cipher_decrypt’:
aead.c:220:43: error: passing argument 9 of ‘crypto_aead_aes256gcm_decrypt_afternm’ from incompatible pointer type [-Werror]
                                           ad, adlen, n, cipher_ctx->aes256gcm_ctx);
                                           ^
In file included from /usr/include/sodium.h:8:0,
                 from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:129:5: note: expected ‘const unsigned char (*)[512]’ but argument is of type ‘unsigned char (*)[512]’
 int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
     ^
cc1: all warnings being treated as errors
make[3]: *** [libshadowsocks_libev_la-aead.lo] Error 1
make[3]: Leaving directory `/<<BUILDDIR>>/shadowsocks-libev-3.2.0-44-ga7877c5+trusty+ixnet.work/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/<<BUILDDIR>>/shadowsocks-libev-3.2.0-44-ga7877c5+trusty+ixnet.work'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/<<BUILDDIR>>/shadowsocks-libev-3.2.0-44-ga7877c5+trusty+ixnet.work'
dh_auto_build: make -j1 returned exit code 2
make: *** [build-arch] Error 2
dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2

What is your config in detail (with all sensitive info masked)?

N/A

@triaqu
Copy link

triaqu commented Sep 12, 2018

我在debian9 下编译成功,在debian8下报错

aead.c: In function 'aead_cipher_encrypt':
aead.c:172:63: error: passing argument 9 of 'crypto_aead_aes256gcm_encrypt_afternm' from incompatible pointer type [-Werror]
ad, adlen, NULL, n, cipher_ctx->aes256gcm_ctx);
^
In file included from /usr/include/sodium.h:8:0,
from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:92:5: note: expected 'const unsigned char ()[512]' but argument is of type 'unsigned char ()[512]'
int crypto_aead_aes256gcm_encrypt_afternm(unsigned char c,
^
aead.c: In function 'aead_cipher_decrypt':
aead.c:220:57: error: passing argument 9 of 'crypto_aead_aes256gcm_decrypt_afternm' from incompatible pointer type [-Werror]
ad, adlen, n, cipher_ctx->aes256gcm_ctx);
^
In file included from /usr/include/sodium.h:8:0,
from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:103:5: note: expected 'const unsigned char (
)[512]' but argument is of type 'unsigned char (*)[512]'
int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
^
cc1: all warnings being treated as errors
Makefile:919: recipe for target 'libshadowsocks_libev_la-aead.lo' failed
make[3]: *** [libshadowsocks_libev_la-aead.lo] Error 1
make[3]: Leaving directory '/root/ss-dev/shadowsocks-libev/src'
Makefile:469: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/root/ss-dev/shadowsocks-libev'
Makefile:377: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/root/ss-dev/shadowsocks-libev'
dh_auto_build: make -j1 returned exit code 2
debian/rules:24: recipe for target 'binary' failed
make: *** [binary] Error 2
dpkg-buildpackage: error: debian/rules binary gave error exit status 2

@XOlegator
Copy link

I had the same error on CentOS 7

$ uname -a
Linux fresh 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I made git checkout 8c98bde - and project was compiled fine.

@triaqu
Copy link

triaqu commented Sep 12, 2018

又在一台新的debian 9 上测试,升级libsodium23,编译成功。
安装deb时也需要安装libsodium23
但在debian 8 上失败。

`dpkg -i shadowsocks-libev_3.2.0-1_amd64.deb
(Reading database ... 43030 files and directories currently installed.)
Preparing to unpack shadowsocks-libev_3.2.0-1_amd64.deb ...
Unpacking shadowsocks-libev (3.2.0-1) over (3.2.0-1) ...
dpkg: dependency problems prevent configuration of shadowsocks-libev:
shadowsocks-libev depends on libsodium23 (>= 1.0.12); however:
Package libsodium23 is not installed.

`

@manjuprajna
Copy link

same here: CentOS 7.5, kernel 4.18.7-1.el7.elrepo.x86_64
aead.c:172:43: error: passing argument 9 of 'crypto_aead_aes256gcm_encrypt_afternm' from incompatible pointer type [-Werror]
ad, adlen, NULL, n, cipher_ctx->aes256gcm_ctx);
^
In file included from /usr/include/sodium.h:8:0,
from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:118:5: note: expected 'const unsigned char ()[512]' but argument is of type 'unsigned char ()[512]'
int crypto_aead_aes256gcm_encrypt_afternm(unsigned char c,
^
aead.c: In function 'aead_cipher_decrypt':
aead.c:220:43: error: passing argument 9 of 'crypto_aead_aes256gcm_decrypt_afternm' from incompatible pointer type [-Werror]
ad, adlen, n, cipher_ctx->aes256gcm_ctx);
^
In file included from /usr/include/sodium.h:8:0,
from aead.c:33:
/usr/include/sodium/crypto_aead_aes256gcm.h:129:5: note: expected 'const unsigned char (
)[512]' but argument is of type 'unsigned char (*)[512]'
int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
^
cc1: all warnings being treated as errors

@zhiyuan-lin
Copy link

zhiyuan-lin commented Sep 13, 2018

@madeye According to my test, this regression is cause by bug in GCC version < 5.

It does not recognize unsigned char (*)[512] argument as acceptable type conversion to function's const unsigned char (*)[512].

It can be fixed by:

  1. Recommend the use of Clang or newer GCC in SCL's Developer Toolset on legacy OS like CentOS 7. Ubuntu 14.04 will be out of offical support soon.
  2. Use forced type conversion to make the argument a (void*), which is not very elegent.

Which do you prefer?

@zhiyuan-lin
Copy link

@fsgmhoward @triaqu @XOlegator @manjuprajna
I confirmed this is a bug with GCC version pre-5.

Here is temporary solution for you to use on older distro.

  1. Install clang
  2. run make clean
  3. run CC=clang ./configure to configure the Makefile to use clang as compiler.
  4. make should be working now.

Alternatively you can install newer GCC, any version newer than >=5.0 should be fine.

@fsgmhoward
Copy link
Author

@edsgerlin
I am using launchpad to build packages automatically and actually using the upstream debian control file. If pre-5 gcc is no longer supported, I would suggest putting this in the configure file (or debian/control?) to make sure gcc >=5 or clang is used.

Anyway I am also not using Ubuntu 12/14 at the moment so I will wait for the final decision on this matter.

@triaqu
Copy link

triaqu commented Sep 13, 2018

echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
apt-get update
apt-get install -t unstable gcc

安装的版本是gcc 8.2.0,编译成功。

@manjuprajna
Copy link

@edsgerlin there are many people using CentOS, now you want people change their OS only for one encryption method that is not so widely used?
how much people using CentOS? (plus old ubuntu and debian versions)? I think at lease 10%.
how much people using aes-256-gcm?
better find a more elegant way.

@zhiyuan-lin
Copy link

@manjuprajna
As for users of CentOS 7, you can either use clang to compile or use the newer GCC in Red Hat Developer Toolset 7 to compile.
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/
No need to change or upgrade OS.
Clang 3.4 is in the offical yum repository of CentOS 7 and does not have such bug.

I only propose to add something to README to guide user using older GCC to use newer one or clang.
So we don't need to write ugly workarounds for deprecated GCC versions.

@madeye madeye closed this as completed Sep 18, 2018
@madeye madeye added the bug label Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants