Eliminate 'dereference of null' CSA false warning in array_mark_proc
authorIvan Maidanski <ivmai@mail.ru>
Tue, 25 Oct 2016 21:56:02 +0000 (00:56 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 25 Oct 2016 21:56:02 +0000 (00:56 +0300)
The exact warning message is: Access to field 'mse_start' results in a
dereference of a null pointer (loaded from variable 'new_mark_stack_ptr').

Note: the warning is eliminated regardless of assertion checking status.

* typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL
(thus orig_mark_stack_ptr is ensured to be non-NULL after the check).

typd_mlc.c

index 7fde0a8..d19e4c1 100644 (file)
@@ -495,6 +495,9 @@ STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
                                                     mark_stack_ptr,
                                                     mark_stack_limit-1);
     if (new_mark_stack_ptr == 0) {
+        /* Explicitly instruct Clang Static Analyzer that ptr is non-null. */
+        if (NULL == mark_stack_ptr) ABORT("Bad mark_stack_ptr");
+
         /* Doesn't fit.  Conservatively push the whole array as a unit  */
         /* and request a mark stack expansion.                          */
         /* This cannot cause a mark stack overflow, since it replaces   */