5

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));
      |                                   ^~~~~~~~
      |             
Edward
  • 468
  • 4
  • 18
  • 1
    you need to include linux/limits.h. [Where is PATH_MAX defined in Linux?](https://stackoverflow.com/q/9449241/995714) – phuclv Jul 22 '21 at 02:37
  • 1
    Does this answer your question? [Where is PATH\_MAX defined in Linux?](https://stackoverflow.com/questions/9449241/where-is-path-max-defined-in-linux) – phuclv Jul 22 '21 at 02: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 Jul 23 '21 at 01: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 [mcve] and show it – phuclv Jul 23 '21 at 01:55
  • @phuclv I can confirm the header was included and that it did not contain PATH_MAX. Defining this in the header made the compilation succeed. I am now in the middle of testing the compiler prior to writing up an answer. – Edward Jul 23 '21 at 02:24
  • 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 Nov 01 '21 at 23:37
  • @c-x-berger The test programs i compiled seemed to work. However, I don't think my testing was adequate. I didn't end up using it in prod. If you can come up with something better please let me know – Edward Nov 02 '21 at 00:04

1 Answers1

0

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>
ishmael
  • 1,796
  • 3
  • 18
  • 19