Blame malloc/tst-tcfree1.c

Packit Bot 4c590a
/* Test that malloc tcache catches double free.
Packit Bot 4c590a
   Copyright (C) 2018 Free Software Foundation, Inc.
Packit Bot 4c590a
   This file is part of the GNU C Library.
Packit Bot 4c590a
Packit Bot 4c590a
   The GNU C Library is free software; you can redistribute it and/or
Packit Bot 4c590a
   modify it under the terms of the GNU Lesser General Public
Packit Bot 4c590a
   License as published by the Free Software Foundation; either
Packit Bot 4c590a
   version 2.1 of the License, or (at your option) any later version.
Packit Bot 4c590a
Packit Bot 4c590a
   The GNU C Library is distributed in the hope that it will be useful,
Packit Bot 4c590a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot 4c590a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Bot 4c590a
   Lesser General Public License for more details.
Packit Bot 4c590a
Packit Bot 4c590a
   You should have received a copy of the GNU Lesser General Public
Packit Bot 4c590a
   License along with the GNU C Library; if not, see
Packit Bot 4c590a
   <http://www.gnu.org/licenses/>.  */
Packit Bot 4c590a
Packit Bot 4c590a
#include <errno.h>
Packit Bot 4c590a
#include <error.h>
Packit Bot 4c590a
#include <limits.h>
Packit Bot 4c590a
#include <malloc.h>
Packit Bot 4c590a
#include <stdlib.h>
Packit Bot 4c590a
#include <stdio.h>
Packit Bot 4c590a
#include <sys/signal.h>
Packit Bot 4c590a
Packit Bot 4c590a
static int
Packit Bot 4c590a
do_test (void)
Packit Bot 4c590a
{
Packit Bot 4c590a
  /* Do one allocation of any size that fits in tcache.  */
Packit Bot 4c590a
  char * volatile x = malloc (32);
Packit Bot 4c590a
Packit Bot 4c590a
  free (x); // puts in tcache
Packit Bot 4c590a
  free (x); // should abort
Packit Bot 4c590a
Packit Bot 4c590a
  printf("FAIL: tcache double free not detected\n");
Packit Bot 4c590a
  return 1;
Packit Bot 4c590a
}
Packit Bot 4c590a
Packit Bot 4c590a
#define TEST_FUNCTION do_test
Packit Bot 4c590a
#define EXPECTED_SIGNAL SIGABRT
Packit Bot 4c590a
#include <support/test-driver.c>