-
Notifications
You must be signed in to change notification settings - Fork 1.5k
iwyu.yml: made include-what-you-use output more verbose / cleaned up includes
#5540
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
Conversation
include-what-you-use output more verboseinclude-what-you-use output more verbose
include-what-you-use output more verboseinclude-what-you-use output more verbose / cleaned up includes
704c4fc to
225d24a
Compare
…ay the whole comment
…ch our include order
…to make it easier to spot false positives
| #endif | ||
|
|
||
|
|
||
| // TODO: __USE_DYNAMIC_STACK_SIZE is depedent on the features.h include and not a built-in compiler define, so it might be problematic to depedent on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like features.h should be included then? Also, 2x typo depedent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to figure out what is actually including this as it seems to be available in all context - I assume that might be caused by the precompiled headers. It is also not available on all platforms so there's a chance it will be breaking some builds (e.g. MacOS does not have it) so it needs some preprocessor checks. I can't be bothered to do any of that right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, 2x typo
depedent.
I will fix those in another PR with several other typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears features.h is included if you include any system header. __USE_DYNAMIC_STACK_SIZE is defined and set to 1 if _DYNAMIC_STACK_SIZE_SOURCE is defined. That in turn is defined if the user specified _GNU_SOURCE.
features.h documents the following:
__USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
But if you look at our code it seems like the check is actually backwards:
#ifdef __USE_DYNAMIC_STACK_SIZE
static const size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
#else
static const size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
#endif
And if you change that code it does not even compile:
cli/cppcheckexecutorsig.cpp:58:13: error: variable length array declaration not allowed at file scope
static char mytstack[MYSTACKSIZE]= {0}; // alternative stack for signal handler
^ ~~~~~~~~~~~
Checking the documentation of stack_t where this is being used:
https://www.gnu.org/software/libc/manual/html_node/Signal-Stack.html
size_t ss_size
This is the size (in bytes) of the signal stack which ‘ss_sp’ points to. You should set this to however much space you allocated for the stack.
There are two macros defined in signal.h that you should use in calculating this size:
SIGSTKSZ
This is the canonical size for a signal stack. It is judged to be sufficient for normal uses.
MINSIGSTKSZ
This is the amount of signal stack space the operating system needs just to implement signal delivery. The size of a signal stack must be greater than this.
For most cases, just using SIGSTKSZ for ss_size is sufficient. But if you know how much stack space your program’s signal handlers will need, you may want to use a different size. In this case, you should allocate MINSIGSTKSZ additional bytes for the signal stack and increase ss_size accordingly.
So we are allocating way too much memory for the stack.
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaltstack.2.html shows an example on how to allocate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also https://reviews.llvm.org/D28265 indicates that using sigaltstack() on MacOS breaks backtrace().
See #5540 (review) for related discussion.
No description provided.