sanitizers | AddressSanitizer , ThreadSanitizer , MemorySanitizer | Machine Learning library

 by   google C Version: Current License: Non-SPDX

kandi X-RAY | sanitizers Summary

kandi X-RAY | sanitizers Summary

sanitizers is a C library typically used in Artificial Intelligence, Machine Learning, Deep Learning, Tensorflow applications. sanitizers has no bugs, it has no vulnerabilities and it has medium support. However sanitizers has a Non-SPDX License. You can download it from GitHub.

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

            kandi-support Support

              sanitizers has a medium active ecosystem.
              It has 9763 star(s) with 945 fork(s). There are 352 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 533 open issues and 1065 have been closed. On average issues are closed in 188 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of sanitizers is current.

            kandi-Quality Quality

              sanitizers has 0 bugs and 8 code smells.

            kandi-Security Security

              sanitizers has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              sanitizers code analysis shows 0 unresolved vulnerabilities.
              There are 2 security hotspots that need review.

            kandi-License License

              sanitizers has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              sanitizers releases are not available. You will need to build from source code and install.
              sanitizers saves you 695 person hours of effort in developing the same functionality from scratch.
              It has 830 lines of code, 12 functions and 12 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sanitizers
            Get all kandi verified functions for this library.

            sanitizers Key Features

            No Key Features are available at this moment for sanitizers.

            sanitizers Examples and Code Snippets

            No Code Snippets are available at this moment for sanitizers.

            Community Discussions

            QUESTION

            Is it safe to use dangerouslySetInnerHTML with hard coded html strings?
            Asked 2022-Apr-09 at 01:31

            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:30

            If 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?

            Source https://stackoverflow.com/questions/71804591

            QUESTION

            Express validator custom function
            Asked 2022-Mar-31 at 06:58

            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:58

            Looks 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:

            Source https://stackoverflow.com/questions/71686367

            QUESTION

            Why does sanitizer give warnings when processing asynchronous boost::asio operations in parallel in my code?
            Asked 2022-Feb-23 at 17:00

            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:57

            I 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 deprecated io_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 manually io_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 new async_wait.
            • You are doing a hard socket.close(). I'd suggest doing a cancel() 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:

            Source https://stackoverflow.com/questions/71239468

            QUESTION

            Can I use Thread Sanitizer on Windows 10?
            Asked 2022-Jan-31 at 10:55

            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:29

            The 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)?

            e.g.: https://godbolt.org/z/fax6o9E1f

            Source https://stackoverflow.com/questions/70894444

            QUESTION

            Why does the thread sanitizer complain about acquire/release thread fences?
            Asked 2022-Jan-04 at 16:06

            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:06

            The 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:

            Source https://stackoverflow.com/questions/70542993

            QUESTION

            kubernetes popeye report JSON to cvs with JQ
            Asked 2021-Dec-14 at 12:41

            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:24

            You 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:

            Source https://stackoverflow.com/questions/70346247

            QUESTION

            V8 Memory leak when using optional chaining in script
            Asked 2021-Dec-10 at 17:47

            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.)

            1. 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.

            1. Why could this occur only when using JS's optional chaining?

            That makes no sense, and I bet that something else is going on.

            1. 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.

            Source https://stackoverflow.com/questions/70157768

            QUESTION

            How do I get an error from `pop_back()` if `size()` is 0?
            Asked 2021-Nov-28 at 10:14

            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:42

            Both 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.

            Source https://stackoverflow.com/questions/70117470

            QUESTION

            Thread Sanitizer - How to interpret the Read vs Previous Write warning
            Asked 2021-Nov-18 at 09:25

            I am running a program with thread sanitizers and wonder how to interpret the following warning:

            ...

            ANSWER

            Answered 2021-Nov-18 at 09:25

            The 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:

            Source https://stackoverflow.com/questions/70016851

            QUESTION

            Using Address Sanitizer or other Undefined Behavior Sanitizers in Production?
            Asked 2021-Nov-17 at 13:11

            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:11

            Sanitizers 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.

            Source https://stackoverflow.com/questions/70003639

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install sanitizers

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/google/sanitizers.git

          • CLI

            gh repo clone google/sanitizers

          • sshUrl

            git@github.com:google/sanitizers.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link