[PATCH] D35690: [Sanitizers] TSan allocator set errno on failure.
Aleksey Shlyapnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 07:57:36 PDT 2017
alekseyshl added inline comments.
================
Comment at: lib/tsan/tests/unit/tsan_mman_test.cc:72
void *p2 = user_realloc(thr, pc, p, 0);
- EXPECT_NE(p2, (void*)0);
+ EXPECT_EQ(p2, (void*)0);
}
----------------
dvyukov wrote:
> dvyukov wrote:
> > Is there a particular reason for this change? If not, then I would prefer to leave the current behavior. It worked for 5 years. We don't know what will happen with this one.
> Note: the current behavior is correct according to both POSIX, linux man pages and C:
>
> If size is 0, either a null pointer or a unique pointer that can be successfully passed to free() shall be returned.
>
> If size was equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
Wait, that's what the man I quoted in comments: "if size is equal to zero, and ptr is not NULL, then the call is equivalent to free(ptr)", so I'm freeing the pointer and it seems only natural to return NULL in this case, cause what else would I return?
What you're saying is correct for user_realloc(thr, pc, NULL, 0) case.
https://reviews.llvm.org/D35690
More information about the llvm-commits
mailing list