7

I'm following this guide but when I try to build the c++ library I get the following fatal error.

../../../../gcc-11.1.0/libsanitizer/asan/asan_linux.cpp: In function ‘void __asan::AsanCheckIncompatibleRT()’:
../../../../gcc-11.1.0/libsanitizer/asan/asan_linux.cpp:199:21: error: ‘PATH_MAX’ was not declared in this scope
  199 |       char filename[PATH_MAX];
      |                     ^~~~~~~~
../../../../gcc-11.1.0/libsanitizer/asan/asan_linux.cpp:200:35: error: ‘filename’ was not declared in this scope; did you mean ‘rename’?
  200 |       MemoryMappedSegment segment(filename, sizeof(filename));
      |                                   ^~~~~~~~
      |             
7
  • 1
    you need to include linux/limits.h. Where is PATH_MAX defined in Linux?
    – phuclv
    Commented Jul 22, 2021 at 2:37
  • 1
    Does this answer your question? Where is PATH_MAX defined in Linux?
    – phuclv
    Commented Jul 22, 2021 at 2:38
  • @phuclv the file in question includes limits.h. It appears the file is found as the preprocessor isn't complaining. I'm not sure how to effectively debug this.
    – Edward
    Commented Jul 23, 2021 at 1:07
  • no, the header isn't included because error: ‘PATH_MAX’ was not declared in this scope is thrown. No one can tell what the problem is because there isn't enough information. You must create a minimal reproducible example and show it
    – phuclv
    Commented Jul 23, 2021 at 1:55
  • 1
    I've had exactly the same issue with that guide myself. Editing limits.h to "fix" it seems... sketchy, did it actually work for you?
    – c-x-berger
    Commented Nov 1, 2021 at 23:37

1 Answer 1

1

This appears to be a bug in libsanitizer/asan/asan_linux.cpp. It seems to find the wrong limits.h file. I was able to work around it by modifying asan_linux.cpp as follows.

-#include <limits.h>
+#include <linux/limits.h>
1
  • There should be a #include_next<limits.h> in the limits.h header installed by glibc but that does not seem to find the next limits.h header..
    – Ezbob
    Commented May 9 at 10:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.