[compiler-rt] r205413 - [msan] Add __msan_check_mem_is_initialized.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Apr 2 05:45:02 PDT 2014


Forgot to "svn add" it.
r205417

On Wed, Apr 2, 2014 at 4:42 PM, Alexey Samsonov <samsonov at google.com> wrote:
> Do you have a test for this?
>
> On Wed, Apr 2, 2014 at 3:50 PM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>> Author: eugenis
>> Date: Wed Apr  2 06:50:42 2014
>> New Revision: 205413
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=205413&view=rev
>> Log:
>> [msan] Add __msan_check_mem_is_initialized.
>>
>> An assert()-like function that checks that a memory range is fully initialized.
>>
>> Modified:
>>     compiler-rt/trunk/include/sanitizer/msan_interface.h
>>     compiler-rt/trunk/lib/msan/msan.cc
>>     compiler-rt/trunk/lib/msan/msan_interface_internal.h
>>
>> Modified: compiler-rt/trunk/include/sanitizer/msan_interface.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/sanitizer/msan_interface.h?rev=205413&r1=205412&r2=205413&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/include/sanitizer/msan_interface.h (original)
>> +++ compiler-rt/trunk/include/sanitizer/msan_interface.h Wed Apr  2 06:50:42 2014
>> @@ -54,6 +54,10 @@ extern "C" {
>>       memory range, or -1 if the whole range is good. */
>>    intptr_t __msan_test_shadow(const volatile void *x, size_t size);
>>
>> +  /* Checks that memory range is fully initialized, and reports an error if it
>> +   * is not. */
>> +  void __msan_check_mem_is_initialized(const volatile void *x, size_t size);
>> +
>>    /* Set exit code when error(s) were detected.
>>       Value of 0 means don't change the program exit code. */
>>    void __msan_set_exit_code(int exit_code);
>>
>> Modified: compiler-rt/trunk/lib/msan/msan.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=205413&r1=205412&r2=205413&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/msan.cc (original)
>> +++ compiler-rt/trunk/lib/msan/msan.cc Wed Apr  2 06:50:42 2014
>> @@ -383,6 +383,22 @@ sptr __msan_test_shadow(const void *x, u
>>    return -1;
>>  }
>>
>> +void __msan_check_mem_is_initialized(const void *x, uptr size) {
>> +  if (!__msan::flags()->report_umrs) return;
>> +  sptr offset = __msan_test_shadow(x, size) < 0;
>> +  if (offset < 0)
>> +    return;
>> +
>> +  GET_CALLER_PC_BP_SP;
>> +  (void)sp;
>> +  __msan::PrintWarningWithOrigin(pc, bp,
>> +                                 __msan_get_origin(((char *)x) + offset));
>> +  if (__msan::flags()->halt_on_error) {
>> +    Printf("Exiting\n");
>> +    Die();
>> +  }
>> +}
>> +
>>  int __msan_set_poison_in_malloc(int do_poison) {
>>    int old = flags()->poison_in_malloc;
>>    flags()->poison_in_malloc = do_poison;
>>
>> Modified: compiler-rt/trunk/lib/msan/msan_interface_internal.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interface_internal.h?rev=205413&r1=205412&r2=205413&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/msan_interface_internal.h (original)
>> +++ compiler-rt/trunk/lib/msan/msan_interface_internal.h Wed Apr  2 06:50:42 2014
>> @@ -65,6 +65,9 @@ SANITIZER_INTERFACE_ATTRIBUTE
>>  sptr __msan_test_shadow(const void *x, uptr size);
>>
>>  SANITIZER_INTERFACE_ATTRIBUTE
>> +void __msan_check_mem_is_initialized(const void *x, uptr size);
>> +
>> +SANITIZER_INTERFACE_ATTRIBUTE
>>  void __msan_set_origin(const void *a, uptr size, u32 origin);
>>  SANITIZER_INTERFACE_ATTRIBUTE
>>  void __msan_set_alloca_origin(void *a, uptr size, const char *descr);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> --
> Alexey Samsonov, MSK



More information about the llvm-commits mailing list