• Bug#1067208: umockdev: #error "_TIME_BITS=64 is allowed only with _FILE

    From Andrey Rakhmatullin@21:1/5 to Thorsten Glaser on Thu Mar 21 10:20:01 2024
    On Wed, Mar 20, 2024 at 03:05:34AM +0000, Thorsten Glaser wrote:
    cc -Ilibumockdev-preload.so.0.0.0.p -I. -I.. -fdiagnostics-color=always -Wall -Winvalid-pch -std=gnu11 -Werror=missing-prototypes -Werror=strict-prototypes -Werror=nested-externs -Werror=pointer-arith -Werror=implicit-function-declaration -Werror=
    implicit-int -Werror=int-conversion -Werror=old-style-definition -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=return-type -Werror=uninitialized -Wcast-align -Wno-error=pragmas -Wno-error=discarded-qualifiers -
    Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-label -Wno-unused-value -Wno-unused-variable -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -
    specs=/usr/share/dpkg/pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fvisibility=default -MD -MQ libumockdev-preload.so.0.0.0.p/
    src_libumockdev-preload.c.o -MF libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o.d -o libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o -c ../src/libumockdev-preload.c
    In file included from /usr/include/features.h:393,
    from /usr/include/assert.h:35,
    from ../src/libumockdev-preload.c:31: /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
    26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
    | ^~~~~


    I admit I don’t exactly see what’s going on here. Does it
    maybe #unset _FILE_OFFSET_BITS or something?
    It does. src/libumockdev-preload.c:

    /* override -D_FILE_OFFSET_BITS, it breaks us */
    #undef _FILE_OFFSET_BITS

    This has the same roots as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065973 as this file
    says "The initial code for intercepting function calls was inspired and partially copied from kmod's testsuite". Maybe it can also have the same
    fix (but that bug isn't fixed yet, though it has a proposed fix).

    --
    WBR, wRAR

    -----BEGIN PGP SIGNATURE-----

    iQJhBAABCgBLFiEEolIP6gqGcKZh3YxVM2L3AxpJkuEFAmX7+kItFIAAAAAAFQAP cGthLWFkZHJlc3NAZ251cGcub3Jnd3JhckBkZWJpYW4ub3JnAAoJEDNi9wMaSZLh vhoP/jqrxMjGwK88eRUfZ4CSVH3utUSPi7JYqWksewntWGT9Q1ARmMDxc+ZxFzBC ZLq1vkOw17yIqsO6QmZ2A7gGTzVnQmDGxRcWINATEnAW8hp4foT/Ncocm6BZWA4k f3HvJ+9yTptgXnWlfgn4nkhgn5bQvoJrb4fYEsNIYHPLgk71bgzkJZkVwE9RHLOQ 4zfUvc0zwMF0fphCw/ItaTNuCYC/zpd3laYx9kHaycdHBPNrAnLla85SViEgxiUc 9Mw4ktIrR1jsqwsRPCusgSvjsg1LcYRb+Vi2NbCsWKAZdmoBX2D3efNj8psYhd5p dhZGLNUiTqXgpWk/lKfqXyNI1KiqkqdvdUsyb38IYPOFiHgZ07fLiwbpEP07uNs0 LV2uixDadfXsdWcmsSoLmcLWUcL/WctXgf6FD9selqVtUDOe72eCH8Lhl6jPBCdW 0F4f6CVREsY4T46hqh3j8ECek64RD7+HJhx8GXaRHvrV5kR8OVOccfRJbCWnnJGQ f6OTO20zVtcrlZXfQSn+r2h0zF0C7Spz0WGqlWn7vJtgBM1Lajt6vh80F+VydRjD 5OBek+Iv45cfgoQnx0oKAmVZnmxAbD76OzFhbOXyFDOdfTpw1AvcBlRIX25pdxAK X/oYrGL2jrq4v45BQodJ173u6PHGnHAhf73PcMqx3IbRJnQC
    =YNdj
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Andrey Rakhmatullin on Thu Mar 21 13:40:01 2024
    On Thu, 21 Mar 2024 at 14:13:38 +0500, Andrey Rakhmatullin wrote:
    On Wed, Mar 20, 2024 at 03:05:34AM +0000, Thorsten Glaser wrote:
    cc -Ilibumockdev-preload.so.0.0.0.p -I. -I.. -fdiagnostics-color=always -Wall -Winvalid-pch -std=gnu11 -Werror=missing-prototypes -Werror=strict-prototypes -Werror=nested-externs -Werror=pointer-arith -Werror=implicit-function-declaration -Werror=
    implicit-int -Werror=int-conversion -Werror=old-style-definition -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=return-type -Werror=uninitialized -Wcast-align -Wno-error=pragmas -Wno-error=discarded-qualifiers -
    Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-label -Wno-unused-value -Wno-unused-variable -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -
    specs=/usr/share/dpkg/pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fvisibility=default -MD -MQ libumockdev-preload.so.0.0.0.p/
    src_libumockdev-preload.c.o -MF libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o.d -o libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o -c ../src/libumockdev-preload.c
    In file included from /usr/include/features.h:393,
    from /usr/include/assert.h:35,
    from ../src/libumockdev-preload.c:31: /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
    26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
    | ^~~~~


    I admit I don’t exactly see what’s going on here. Does it
    maybe #unset _FILE_OFFSET_BITS or something?
    It does. src/libumockdev-preload.c:

    /* override -D_FILE_OFFSET_BITS, it breaks us */
    #undef _FILE_OFFSET_BITS

    This has the same roots as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065973 as this file
    says "The initial code for intercepting function calls was inspired and partially copied from kmod's testsuite". Maybe it can also have the same
    fix (but that bug isn't fixed yet, though it has a proposed fix).

    This appears to be because umockdev is based on a LD_PRELOAD module that interposes wrapped or mock versions of glibc functions like stat() that
    are sensitive to the sizes of off_t and time_t.

    I don't think the proposed fix in kmod is correct, and I don't think
    an equivalent in umockdev would be correct either. Since glibc 2.34,
    on 32-bit architectures all such LD_PRELOAD modules will need updating
    to also wrap __lstat64_time64(), __stat64_time64(), __fstat64_time64()
    and __fstatat64_time64() on architectures where they exist - otherwise, programs and libraries compiled with 64-bit time_t will bypass the
    wrapped stat(), stat64() etc. and call __stat64_time64() instead, and
    therefore the wrapping will be ineffective and umockdev's mock devices
    will not be seen.

    fakeroot, fakechroot and other LD_PRELOAD modules that interpose stat()
    will already be doing something similar, and might provide a useful
    reference for what is needed. Here's the equivalent in fakechroot: https://github.com/dex4er/fakechroot/pull/104/commits/dac74cd68cfb6eeaae9cd13bdc48737a44980df9

    smcv

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)