sanitizers | AddressSanitizer , ThreadSanitizer , MemorySanitizer | Machine Learning library
kandi X-RAY | sanitizers Summary
kandi X-RAY | sanitizers Summary
This project is the home for Sanitizers: AddressSanitizer, MemorySanitizer, ThreadSanitizer, LeakSanitizer, and more The actual code resides in the LLVM repository. Here we keep extended documentation, bugfixes and some helper code.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sanitizers
sanitizers Key Features
sanitizers Examples and Code Snippets
Community Discussions
Trending Discussions on sanitizers
QUESTION
We have an alert component that renders important information for the user. However, this component has somewhat an abstraction where you just need to pass the content as an array of string.
...ANSWER
Answered 2022-Apr-09 at 01:30If you, the coder, create all of the the HTML to be inserted, and are sure that it doesn't have any XSS vulnerabilities, then yes, it'll be safe.
dangerouslySetInnerHTML
is named as such to tell you primarily that, if used incorrectly, it's very easy to open your app up to security problems. But if the HTML that gets set is hard-coded and safe, then dangerouslySetInnerHTML
is safe too.
Sanitizers are necessary when the markup comes from user input, or from an external service. They're not needed if the markup comes entirely from your own code.
That said, in this particular situation:
However, we need to bolden parts of the text for emphasis
Why not just use JSX instead?
QUESTION
I'm trying to write a custom validator for an express API. I can't figure out how I can reject incorrect values from the custom validator. Here's what I have:
...ANSWER
Answered 2022-Mar-31 at 06:58Looks like you are over-complicating the validator.
First, .catch()
should take an argument as a general rule.
Here, you do want the promise to reject in case of invalidation, so you don't need to catch.
How about:
QUESTION
I am decided to test my project written using boost::asio (I run io_service::run in different threads) with all kinds of sanitizers and on thread-sanitizer got data race, namely it reported that socket is at the same time checked for is_open somewhere inside io_service and is at the same time closed due to timeout. I managed to repeat the problem on small code, but I don't understand why it occurs, shouldn't it build a chain using boost::asio::io_service::strand and synchronize a single object of class D (from the example below) relative to other threads? Please help, thank you!
...ANSWER
Answered 2022-Feb-23 at 16:57I couldn't reproduce the problem. I have reviewed the code.
- There's some dead code in your question (
f
). - You're not using recent interfaces, consider using
io_context
instead of the deprecatedio_service
interface. - You can be much more safe/succinct by constructing your IO objects directly on the strand executor, rather than on the general service. This means that all completions will happen on the strand by default.
- The 500 ms wait "for all threads to be created" does nothing, because
join_all
on a thread_group already blocks until the service exits (runs out of work). - Consider using
asio::thread_pool
instead of manuallyio_context
+thread_group
. It comes down to the same but with more correctness (see e.g. Should the exception thrown by boost::asio::io_service::run() be caught?) - you never initially set the time expiration before your first
async_wait
. You also don't reset it when chaining a newasync_wait
. - You are doing a hard
socket.close()
. I'd suggest doing acancel()
instead and leaving the close to the destructor. This prevents a category of bugs surrounding reused socket fds (which aren't even detectable as data races, because they are application level races). - I'm not too sure in the first place why aborted timers restart in the first place. Shouldn't you just wait until a new socket operation is attempted that required a timeout?
- It seems pretty counter-productive to wait 100ms before canceling the timer. That just makes it so the socket might well be closed even if connection did complete in timely fashion? [Perhaps this is just because the sample code is removed so much other code.]
With that said, here's a simplified listing. I did not see data race in your code. I will look at the reports when you add them.
For now, hopefully this review might help you:
QUESTION
I'd like to test data races in C++ on windows 10(64 bit), but it seems that Visual C++ doesn't support it yet.
So, I installed Cygwin and got g++ 11.2.0, tried compiling my C++ code with -fsanitize=thread -fPIE -pie -g
, but it failed with -ltsan not found
error.
The doc doesn't say anything about Windows. Is it even possible to use Thread Sanitizer on Windows? If so, How?
...ANSWER
Answered 2022-Jan-28 at 13:29The sanitizers you linked are implemented in Clang, not MSVC or gcc. You can use clang with Visual Studio. To do so you need to install the appropiate toolchain. You can run clang directly on Windows, via cygwin or via WSL.
In addition could you post your complete compile command (e.g. via godbolt.org)?
QUESTION
I'm learning about different memory orders.
I have this code, which works and passes GCC's and Clang's thread sanitizers:
...ANSWER
Answered 2022-Jan-04 at 16:06The thread sanitizer currently doesn't support std::atomic_thread_fence
. (GCC and Clang use the same thread sanitizer, so it applies to both.)
GCC 12 (currently trunk) warns about it:
QUESTION
I need to reformat the Popeye Kubernetes report in a spreadsheet. I used jq but it's a bit tricky.
...ANSWER
Answered 2021-Dec-14 at 09:24You are asking for a CSV export but you are showing an object as desired format. So, I interpreted the object's fields as CSV columns:
QUESTION
I've embedded V8 9.5 into my app (C++ HTTP server). When I started to use optional chaining in my JS scripts I've noticed abnormal rise in memory consumption under heavy load (CPU) leading to OOM. While there's some free CPU, memory usage is normal. I've displayed V8 HeapStats in grafana (this is only for 1 isolate, which I have 8 in my app)
Under heavy load there's a spike in peak_malloced_memory
, while other stats are much less affected and seem normal.
I've passed --expose-gc
flag to V8 and called gc()
at the end of my script. It completely solved the problem and peak_malloced_memory
doesn't rise like that. Also, by
repeatedly calling gc()
I could free all extra memory consumed without it. --gc-global
also works. But these approaches seem more like a workaround rather than a production-ready solution.
--max-heap-size=64
and --max-old-space-size=64
had no effect - memory consumption still did greatly exceed 8(number of isolates in my app)*64Mb (>2Gb physical RAM).
I don't use any GC-related V8 API in my app.
My app creates v8::Isolate
and v8::Context
once and uses them to process HTTP requests.
Same behavior at v9.7.
Ubuntu xenial
Built V8 with these args.gn
...ANSWER
Answered 2021-Nov-29 at 17:46(V8 developer here.)
- Is it normal that peak_malloced_memory can exceed total_heap_size?
Malloced memory is unrelated to the heap, so yes, when the heap is tiny then malloced memory (which typically also isn't a lot) may well exceed it, maybe only briefly. Note that peak malloced memory (53 MiB in your screenshot) is not current malloced memory (24 KiB in your screenshot); it's the largest amount that was used at any point in the past, but has since been freed (and is hence not a leak, and won't cause an OOM over time).
Not being part of the heap, malloced memory isn't affected by --max-heap-size
or --max-old-space-size
, nor by manual gc()
calls.
- Why could this occur only when using JS's optional chaining?
That makes no sense, and I bet that something else is going on.
- Are there any other, more correct solutions to this problem other than forcing full GC all the time?
I'm not sure what "this problem" is. A brief peak of malloced memory (which is freed again soon) should be fine. Your question title mentions a "leak", but I don't see any evidence of a leak. Your question also mentions OOM, but the graph doesn't show anything related (less than 10 MiB current memory consumption at the end of the plotted time window, with 2GB physical memory), so I'm not sure what to make of that.
Manually forcing GC runs is certainly not a good idea. The fact that it even affects (non-GC'ed!) malloced memory at all is surprising, but may have a perfectly mundane explanation. For example (and I'm wildly speculating here, since you haven't provided a repro case or other more specific data), it could be that the short-term peak is caused by an optimized compilation, and with the forced GC runs you're destroying so much type feedback that the optimized compilation never happens.
Happy to take a closer look if you provide more data, such as a repro case. If the only "problem" you see is that peak_malloced_memory
is larger than the heap size, then the solution is simply not to worry about it.
QUESTION
I was explaining to a coworker why we have small test with sanitizers on them. He asked about popping a vector too many times and if it was an exception, assert, UB and which sanitizer catches it
It appears NONE catches them. Address and memory will if you call back()
after popping too many times but if you pop and do size()
you get a large invalid value due to wrapping
Is there a way I can get an assert or exception or runtime termination when I pop too many times? I really thought a debug build without sanitizers would have caught that (with an assert or exception)
I use clang sanitizer but build options with gcc will also be helpful
...ANSWER
Answered 2021-Nov-25 at 21:42Both libstdc++ and libc++ have a "debug mode" with assertions, that can be enabled using:
-D_GLIBCXX_DEBUG
for libstdc++-D_LIBCPP_DEBUG
for libc++
Also -fsanitize=undefined
appears to catch it, but the error message is much more cryptic.
QUESTION
I am running a program with thread sanitizers and wonder how to interpret the following warning:
...ANSWER
Answered 2021-Nov-18 at 09:25The warning is a real error (unless it is a false positive).
Thread T27 wrote 8 bytes to address 0x7f7eefc4e298
and main thread read the first 4 bytes of that later without locking (as far as the sanitizer could tell). This is a race condition and undefined behaviour.
In other words, access to 0x7f7eefc4e298
is not protected by locks or other synchronization primitives. Is that the case?
If you insist, there is a way how to silence them, create a supp.txt
file with:
QUESTION
In the past there have been concerns about using ASAN in production in certain environments: https://seclists.org/oss-sec/2016/q1/363 . The comment is from 2016 - what is the landscape like today?
Is it recommendable to use the sanitizers here in a production system running on a user's device? The application receives untrusted input from other parties and processes these in various ways.
Are there security relevant impacts from using them? Do any of the added instrumentations actually make it easier to remotely exploit a bug?
The application I'm considering this for is open source, so easing reverse engineering would not be an issue for in this case.
...ANSWER
Answered 2021-Nov-17 at 13:11Sanitizers are primarily meant to be used as debug, not hardening tools i.e. for error detection at verification stage but not error prevention in production. Otherwise they may leak sensitive info to the attacker (by printing details about address space and library version to stderr on error) or obtain local root privileges due to uncontrolled use of environment variables. Also sanitizers may add quite a bit of overhead (2x slowdowns are not uncommon for Asan, 1.5x for UBsan).
In general sanitizers are sometimes used in production environment for A/B testing, to increase coverage and detect bugs which escaped normal QA.
Clang has many options for hardening: fortification (-D_FORTIFY_SOURCE=2
), ASLR (-fPIE
),
stack protection (-fstack-protector
, -fsanitize=safe-stack
) and control-flow integrity (-fsanitize=cfi
) (see Clang Hardening Cheatsheet for details). They have a much smaller overhead and are specifically meant to be used in production.
UPDATE (thanks to @cisnjxqu):
UBsan supports the -fsanitize-minimal-runtime
mode which provides minimalistic, low-overhead runtime library which is supposed to not increase the application attack surface.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sanitizers
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page