mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Upgrade gperftools to 2.9 for GCP/GMC/GMP/GMD. (#2247)
This commit is contained in:
parent
63da0dca92
commit
44e9dc83e9
346 changed files with 169666 additions and 78 deletions
10
trunk/research/gperftools/heap-defense/Makefile
Normal file
10
trunk/research/gperftools/heap-defense/Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
.PHONY: default clean
|
||||
|
||||
default: heap_defense
|
||||
|
||||
heap_defense: heap_defense.cc Makefile
|
||||
g++ -o heap_defense heap_defense.cc -g -O0 -ansi \
|
||||
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
|
||||
-I../../../objs/gperf/include ../../../objs/gperf/lib/libtcmalloc_debug.a -lpthread
|
||||
clean:
|
||||
rm -rf heap_defense ./*.dSYM
|
30
trunk/research/gperftools/heap-defense/heap_defense.cc
Normal file
30
trunk/research/gperftools/heap-defense/heap_defense.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// Copyright (c) 2013-2021 Winlin
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
/**
|
||||
@see: https://blog.csdn.net/win_lin/article/details/50461709
|
||||
config srs with gperf(to make gperftools):
|
||||
./configure --gperf=on --gmd=on --jobs=3
|
||||
to check mem corruption:
|
||||
make && env TCMALLOC_PAGE_FENCE=1 ./heap_defense
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
void foo(char* buf) {
|
||||
buf[16] = 0x0f;
|
||||
}
|
||||
|
||||
void bar(char* buf) {
|
||||
printf("buf[15]=%#x\n", (unsigned char)buf[15]);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char* buf = new char[16];
|
||||
foo(buf);
|
||||
bar(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue