Blame malloc/tst-tcfree1.c

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