zopefoundation / AccessControl

Security framework for Zope.
Other
12 stars 16 forks source link

Build failure on FreeBSD 14 with clang 16 and python3.9 #149

Closed n12i closed 3 months ago

n12i commented 6 months ago

BUG/PROBLEM REPORT / FEATURE REQUEST

What I did:

mkdir Plone6 && cd Plone6 virtuanenv-3.9 zinstance cd zinstance bin/pip install zc.buildout cat >buildout.cfg <<EOF [buildout] extends = http://dist.plone.org/release/6-latest/versions.cfg

parts = instance

[instance] recipe = plone.recipe.zope2instance user = admin:admin http-address = 8080 eggs = Plone EOF ./bin/buildout

What I expect to happen:

Generated script '.../Plone6/zinstance/bin/instance'. Generated interpreter '.../Plone6/zinstance/parts/instance/bin/interpreter'.

What actually happened:

[snip] creating build/temp.freebsd-14.0-RELEASE-p6-amd64-cpython-39/src/AccessControl cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -Iinclude -Isrc -I/usr/home/nakaji/Plone6/zinstance/include -I/usr/local/include/python3.9 -c src/AccessControl/cAccessControl.c -o build/temp.freebsd-14.0-RELEASE-p6-amd64-cpython-39/src/AccessControl/cAccessControl.o src/AccessControl/cAccessControl.c:428:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion] NULL, / tp_print */ ^~~~ /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'

define NULL ((void *)0)

                  ^~~~~~~~~~~  
  src/AccessControl/cAccessControl.c:487:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
          NULL,                                   /* tp_print     */
          ^~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  src/AccessControl/cAccessControl.c:546:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
          NULL,                                   /* tp_print     */
          ^~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  src/AccessControl/cAccessControl.c:616:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
          NULL,                                   /* tp_print     */
          ^~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  src/AccessControl/cAccessControl.c:546:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
          NULL,                                   /* tp_print     */
          ^~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  src/AccessControl/cAccessControl.c:616:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
          NULL,                                   /* tp_print     */
          ^~~~
  /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
  #define NULL    ((void *)0)
                  ^~~~~~~~~~~
  4 errors generated.
  error: command '/usr/bin/cc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for AccessControl ERROR: Could not build wheels for AccessControl, which is required to install pyproject.toml-based projects An error occurred when trying to install /tmp/tmpzakznsmqget_dist/AccessControl-6.3.tar.gz. Look above this message for any errors that were output by pip install.

What version of Python and Zope/Addons I am using:

% freebsd-version 14.0-RELEASE-p6 % ./bin/python --version Python 3.9.18 % cc -v FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152) Target: x86_64-unknown-freebsd14.0 Thread model: posix InstalledDir: /usr/bin

icemac commented 6 months ago

I would have expected that one of our pre-built wheels gets installed. What happens if you create a new virtual environment and install AccessControl there via pip?

n12i commented 6 months ago

(modified, sorry) % virtualenv-3.9 accesscontrol % cd accesscontrol % ./bin/pip install -v --no-cache-dir AccessControl got the same NULL error.

cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -Iinclude -Isrc -I/usr /home/nakaji/Plone6/accesscontrol/include -I/usr/local/include/python3.9 -c src/ AccessControl/cAccessControl.c -o build/temp.freebsd-13.3-RELEASE-p1-amd64-cpyth on-39/src/AccessControl/cAccessControl.o src/AccessControl/cAccessControl.c:428:2: error: incompatible pointer to integ er conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion] 428 | NULL, / tp_print / | ^~~~ /usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL' 32 | #define NULL ((void )0) | ^~~ (snip)

Clang 16 says it is an error, and gcc13 just warns.

n12i commented 6 months ago

According to the error/warn message, I changed NULL to 0 and the build was successful. Patch: https://www.heimat.gr.jp/~nakaji/FreeBSD/AccessControl.diff

icemac commented 6 months ago

@n12i Nice finding! Could you please create a pull request with your diff to see the result on the systems we automatically test?

d-maurer commented 6 months ago

NAKAJI Hiroyuki wrote at 2024-4-24 22:29 -0700:

According to the error/warn message, I changed NULL to 0 and the build was successful. Patch: https://www.heimat.gr.jp/~nakaji/FreeBSD/AccessControl.diff

If I have understood your initial report correctly, then the problem has been associated with a line associated with tp_print (a function pointer field) but the compiler expected a size field. This would be something serious -- not really resolved by replacing "NULL" by "0".

n12i commented 6 months ago

If I have understood your initial report correctly, then the problem has been associated with a line associated with tp_print (a function pointer field) but the compiler expected a size field. This would be something serious -- not really resolved by replacing "NULL" by "0".

Agree. My patch can compile cAccessControl.c but I'm not sure if it works correctly.

Similar to these pull requests? https://github.com/tgalal/python-axolotl-curve25519/pull/26 https://github.com/tgalal/python-axolotl-curve25519/pull/28 https://github.com/python-postgres/fe/pull/125

icemac commented 5 months ago

There is now https://github.com/zopefoundation/AccessControl/pull/150 merged, could you please try whether this also fixes your problem?

davisagli commented 5 months ago

I have a project where I can't use the fix in #150 because it's an old project that requires an older major version of AccessControl.

Aside from the problem of casting a pointer to an integer, which is what #150 fixed, I think the problem started happening because clang made a change to raise an error instead of a warning in this scenario: https://reviews.llvm.org/D129881

It might be possible to build an older version of AccessControl by setting CFLAGS="-Wno-error=int-conversion" but I'm waiting for feedback from my colleague on whether this works.

jessesnyder commented 4 months ago

I can confirm that setting CFLAGS="-Wno-error=int-conversion" allowed me to build AccessControl-4.3-py3.8-macosx-14.5-arm64.egg.

n12i commented 4 months ago

There is now #150 merged, could you please try whether this also fixes your problem?

Thanks. This fixes my problem with one waning generated.

src/AccessControl/cAccessControl.c:2202:7: warning: code will never be executed [-Wunreachable-code] 2202 | unauthErr(name, v); | ^~~~~ 1 warning generated.

icemac commented 3 months ago

@n12i I think this warning was already there before.