Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[sanitizer] Undef _TIME_BITS along with _FILE_OFFSET_BITS #99699

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

Closed
wants to merge 1 commit into from

Conversation

tpetazzoni
Copy link
Contributor

This change is identical to
26800a2 ("[sanitizer] Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris specific, it also gets built on Linux platforms. It also includes sanitizer_platform.h, which also ends up including features-time64.h, causing a build failure on 32-bit Linux platforms on which 64-bit time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway will cause no harm as the rest of this file is inside a SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al lowed only with _FILE_OFFSET_BITS=64"
26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
| ^~~~~

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jul 19, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Thomas Petazzoni (tpetazzoni)

Changes

This change is identical to
26800a2 ("[sanitizer] Undef _TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris specific, it also gets built on Linux platforms. It also includes sanitizer_platform.h, which also ends up including features-time64.h, causing a build failure on 32-bit Linux platforms on which 64-bit time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway will cause no harm as the rest of this file is inside a SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al lowed only with _FILE_OFFSET_BITS=64"
26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
| ^~~~~


Full diff: https://github.com/llvm/llvm-project/pull/99699.diff

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp (+1)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
index eeb49e2afe34d..1b23fd4d512b8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
@@ -11,6 +11,7 @@
 
 // Before Solaris 11.4, <procfs.h> doesn't work in a largefile environment.
 #undef _FILE_OFFSET_BITS
+#undef _TIME_BITS
 #include "sanitizer_platform.h"
 #if SANITIZER_SOLARIS
 #  include <fcntl.h>

@rorth
Copy link
Collaborator

rorth commented Jul 19, 2024

Thanks for the patch. A couple of comments:

  • You should request one or more reviewers (the last ones to review the file(s) in question are a good bet), otherwise the patch is most likely overlooked/ignored. I only noticed it due to your equivalent gcc-patches post.
  • Please indicate which target (triple) you noticed the problem on and where/how you tested the patch.
  • The #undef needs a comment explaining why it's needed, especially given that this is a Solaris-specific file and Solaris doesn't have/care about _TIME_BITS.

@tpetazzoni
Copy link
Contributor Author

Thanks for the patch. A couple of comments:

Thanks a lot for the quick feedback!

* You should request one or more reviewers (the last ones to review the file(s) in question are a good bet), otherwise the patch is most likely overlooked/ignored.  I only noticed it due to your equivalent `gcc-patches` post.

Thanks for noticing my patch then. It looks like you are the last person who made changes to this file, so I guess you're the right person to request a review from. I see @richlowe also contributed to this file 3 years ago.

* Please indicate which target (triple) you noticed the problem on and where/how you tested the patch.

The patch was actually tested on the GCC code base, when building an i686 glibc toolchain. But the problem exists for all 32-bit architectures for which libsanitizer has support for, when building with -D_TIME_BITS=64.

* The `#undef` needs a comment explaining why it's needed, especially given that this is a Solaris-specific file and Solaris doesn't have/care about `_TIME_BITS`.

It may be a Solaris-specific file, but it gets compiled unconditionally regardless of the current platform. I'll add a comment that explains things.

@tpetazzoni tpetazzoni force-pushed the fix-sanitizer-64bit-time branch from 716a024 to 920de81 Compare July 20, 2024 09:29
@tpetazzoni
Copy link
Contributor Author

I have force pushed a new version of the patch, with a more detailed comment.

@mgorny mgorny requested review from MaskRay, rorth and devnexen October 7, 2024 17:44
Copy link
Member

@mgorny mgorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that it fixes the build failure on a time64 x86 system, and given that I wanted to make an identical change myself, LGTM.

@mgorny
Copy link
Member

mgorny commented Oct 7, 2024

Also, I think we should backport this to 19.x too.

Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable, but @rorth is the solaris expert.

Copy link
Collaborator

@rorth rorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I appreciate having a comment here, this seems way too long to me. Maybe something like

Avoid conflict between `_TIME_BITS` defined vs. `_FILE_OFFSET_BITS` undefined in some Linux configurations.

or something like this. Certainly not more than a line or two.

This won't affect Solaris at all: its headers contain no reference to _TIME_BITS whatsoever.

@mgorny
Copy link
Member

mgorny commented Oct 10, 2024

@tpetazzoni, sorry to ping you, but are you still around?

This change is identical to
26800a2 ("[sanitizer] Undef
_TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for
sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris
specific, it also gets built on Linux platforms. It also includes
sanitizer_platform.h, which also ends up including features-time64.h,
causing a build failure on 32-bit Linux platforms on which 64-bit
time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway
will cause no harm as the rest of this file is inside a
SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al
lowed only with _FILE_OFFSET_BITS=64"
   26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
      |     ^~~~~

Signed-off-by: Thomas Petazzoni <[email protected]>
@tpetazzoni tpetazzoni force-pushed the fix-sanitizer-64bit-time branch from 920de81 to 9be1bde Compare October 10, 2024 14:35
@tpetazzoni
Copy link
Contributor Author

Sorry for the delay, and thanks for the ping. I just pushed a new update, with the commit rebased on the current main, and a shorter comment, as requested by @rorth. Thanks for the review!

Copy link
Collaborator

@rorth rorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for your patience.

@mgorny
Copy link
Member

mgorny commented Oct 14, 2024

@tpetazzoni, can you merge it or do you need us to merge it for you?

@thesamesam
Copy link
Member

Pushed, thank you!

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Oct 14, 2024
This change is identical to
26800a2 ("[sanitizer] Undef
_TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for
sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris
specific, it also gets built on Linux platforms. It also includes
sanitizer_platform.h, which also ends up including features-time64.h,
causing a build failure on 32-bit Linux platforms on which 64-bit
time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway
will cause no harm as the rest of this file is inside a
SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al
lowed only with _FILE_OFFSET_BITS=64"
   26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
      |     ^~~~~

Signed-off-by: Thomas Petazzoni <[email protected]>
Closes: llvm#99699
(cherry picked from commit a121702)
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
This change is identical to
26800a2 ("[sanitizer] Undef
_TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for
sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris
specific, it also gets built on Linux platforms. It also includes
sanitizer_platform.h, which also ends up including features-time64.h,
causing a build failure on 32-bit Linux platforms on which 64-bit
time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway
will cause no harm as the rest of this file is inside a
SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al
lowed only with _FILE_OFFSET_BITS=64"
   26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
      |     ^~~~~

Signed-off-by: Thomas Petazzoni <[email protected]>
Closes: llvm#99699
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Oct 28, 2024
This change is identical to
26800a2 ("[sanitizer] Undef
_TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for
sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris
specific, it also gets built on Linux platforms. It also includes
sanitizer_platform.h, which also ends up including features-time64.h,
causing a build failure on 32-bit Linux platforms on which 64-bit
time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway
will cause no harm as the rest of this file is inside a
SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al
lowed only with _FILE_OFFSET_BITS=64"
   26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
      |     ^~~~~

Signed-off-by: Thomas Petazzoni <[email protected]>
Closes: llvm#99699
(cherry picked from commit a121702)
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request May 21, 2025
A number of items are removed because the issues have been resolved
with recipe patches (in separate commits).

Some issues were resolved via upstream version updates that bring in
needed fixes:

glib-2.0 update to 2.78.0 that includes:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3547
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3550

curl update to 8.3.0 that includes
curl/curl#11610

util-linux update to 2.39 that includes
util-linux/util-linux#2430
util-linux/util-linux@3ab9e69
util-linux/util-linux#2435

glib-networking update to 2.78.0 that includes
https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/241

python3-cryptography update to 42.0.0 which resolves
pyca/cryptography#9370 via
pyca/cryptography#9964

perl update to 5.40.0 which includes
Perl/perl5#21379

python3 update to 3.13.0 which includes
python/cpython#118425
python3 update to 3.13.1 which includes
python/cpython#124972

tcl update to 9.0.0 which includes
tcltk/tcl@4ca6172
(tcl8 recipe has a simple backport of this)

dbus update to 1.16.0 which includes
https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/444
https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/289

openssh update to 10.0p1 which includes
openssh/openssh-portable#425
https://bugzilla.mindrot.org/show_bug.cgi?id=3684
https://marc.info/?l=openbsd-bugs&m=172561736524815&w=2
https://lists.mindrot.org/pipermail/openssh-unix-dev/2024-October/041621.html
(all reporting the same issue)

gcc update to 15.1 which includes
llvm/llvm-project#99699
via gcc-mirror/gcc@fa32100
and allows dropping special flags and exceptions for gcc-sanitizers.

Signed-off-by: Alexander Kanavin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants