未验证 提交 b470d3b0 编写于 作者: O openharmony_ci 提交者: Gitee

!859 3.2 realase 分支 libc-test safeunlink概率性失败

Merge pull request !859 from wangchen/0329_r
...@@ -27,6 +27,8 @@ static void handler(int s) ...@@ -27,6 +27,8 @@ static void handler(int s)
volatile void *tmp; volatile void *tmp;
#define MALLOC_SIZE 40
int set_devide_chunk(size_t size) int set_devide_chunk(size_t size)
{ {
if (!(tmp = malloc(size))) { if (!(tmp = malloc(size))) {
...@@ -39,10 +41,11 @@ int set_devide_chunk(size_t size) ...@@ -39,10 +41,11 @@ int set_devide_chunk(size_t size)
static int child(void) static int child(void)
{ {
uintptr_t *c; uintptr_t *c;
uintptr_t *d;
uintptr_t *temp; uintptr_t *temp;
/* Set first dividing chunk */ /* Set first dividing chunk */
if (set_devide_chunk(sizeof(size_t))) if (set_devide_chunk(MALLOC_SIZE))
return -1; return -1;
/* /*
...@@ -51,14 +54,33 @@ static int child(void) ...@@ -51,14 +54,33 @@ static int child(void)
* bin[0] and malloc again. Basically this is heap spray. * bin[0] and malloc again. Basically this is heap spray.
*/ */
for (int i = 0; i < 512; ++i) { for (int i = 0; i < 512; ++i) {
if (set_devide_chunk(sizeof(size_t))) c = (uintptr_t *)malloc(MALLOC_SIZE);
return -1;
c = (uintptr_t *)malloc(sizeof(uintptr_t));
if (!c) { if (!c) {
t_error("Malloc failed: %s\n", strerror(errno)); t_error("Malloc failed: %s\n", strerror(errno));
return -1; return -1;
} }
free(c);
if (set_devide_chunk(MALLOC_SIZE)) {
free((void *)c);
return -1;
}
d = (uintptr_t *)malloc(MALLOC_SIZE);
if (!d) {
t_error("Malloc failed: %s\n", strerror(errno));
free((void *)c);
return -1;
}
if (set_devide_chunk(MALLOC_SIZE)) {
free((void *)d);
free((void *)c);
return -1;
}
free((void *)d);
free((void *)c);
/* exchange the prev and next pointer */ /* exchange the prev and next pointer */
uintptr_t temp = c[0]; uintptr_t temp = c[0];
c[0] = c[1]; c[0] = c[1];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册