-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Provide runtime builds with sanitizer support #4819
Comments
I'd prefer not to add further library sets if possible. Option C is doable easily and doesn't have any downsides (for existing |
The main downside of C is that programs with ASan will run very slow and that you don't catch bugs that your actual program (optimized) will have. For that reason, I don't think C is a real viable option... |
Is shipping two libraries with and without sanitisers support a bit bloat? I mean, I think it would be easier to do so, and when the compiler has The option A has some performance problems that I think can be improved, the optional link lookup isn't memoized well, AFAIK, but I would still not prefer it. Release need to avoid having unnecessary stuff, in my view. For weka doesn't make a difference, so A is probably viable for Weka, because we build druntime ourselves anyway, but I'm thinking for the general case ofc. I think to have a seamless experience, option C is not viable, so I would go for option B or a diff/improved version of option B. |
Regarding |
Another option: using |
This is effectively what druntime does now. |
The memoizing I'm talking about is mainly on non-happy flow of |
|
To use sanitizers like AddressSanitizer, you need druntime support if the user's program uses fibers or if ASan's fakestack is enabled (
Use after return
error detection enabled).There is some overhead associated with sanitizer support in druntime, which is why it is disabled by default. The overhead involves memory lookup (cache impacts) for every GC scan and fiber switch. I have not quantified this overhead. Perhaps it is small because a GC scan is already a huge operation with a large cache load. Moreover,
CheckFiberMigration
is set to true when sanitizer support is enabled; I think the consensus is that migrating fibers is bad, but it is allowed in druntime on e.g. Linux.To get druntime support, you have to build druntime with
-d-version=SupportSanitizers
. Building LDC with cmake variableRT_SUPPORT_SANITIZERS
set will do just that.It is quite cumbersome to have to rebuild the druntime (and link with it) to get sanitizer support. We currently don't have LDC packages that have sanitizer support built into druntime, making it much harder to do CI testing with sanitizers enabled (CI would have to rebuild druntime).
I want to make that much simpler, hopefully so simple that just
-fsanitize=address
is enough (automatically checks whether druntime with sanitizer support is available and links with that).I see a few options to get there, and need your help to decide which direction to go.
Option A: default build druntime with sanitizer support.
Option B: provide separate druntime libraries with sanitizer support
This is similar to how we have optimized and debug druntime library builds. This option means adding 4 files: libdruntime-ldc-supportsan.a, libdruntime-ldc-debug-supportsan.a, libdruntime-ldc-debug-supportsan-shared.dylib, libdruntime-ldc-supportsan-shared.dylib. We could make LDC automatically check for a supportsan library when
-fsanitize=address
is used.Option C: Support only for debug builds, default enabled in debug druntime lib.
(Edit) Option D: Support sanitizers in debug build (default on), and separate optimized druntime library with optimization on.
This option means adding 2 files: libdruntime-ldc-supportsan.a and libdruntime-ldc-supportsan-shared.dylib.
Other options?
Note: for C++/clang there is no problem (no separate runtime binary needed besides the ASan library that overrides several std C lib functions), because the relevant parts of the standard/runtime library are templated and hence always recompiled with/without sanitizer support (e.g. for container annotation, https://github.com/llvm/llvm-project/blob/d080f78772acf9de4961b89062c02fdd5f82186a/libcxx/include/__debug_utils/sanitizers.h#L83-L100).
The text was updated successfully, but these errors were encountered: