From 3bd70d75ea66ff6d1bb03acf3ac2b2501cf787c3 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:50:49 +0800 Subject: [PATCH] fix segfault, kcpp is now debuggable --- Makefile | 23 +++++++++++++++++------ examples/llava/clip.cpp | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0d619238b..a413190c6 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,23 @@ endif # # keep standard at C11 and C++11 -CFLAGS = -I. -Iggml/include -Iggml/src -Iinclude -Isrc -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -DNDEBUG -std=c11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_LLAMAFILE -CXXFLAGS = -I. -Iggml/include -Iggml/src -Iinclude -Isrc -I./common -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -DNDEBUG -std=c++11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_LLAMAFILE +CFLAGS = +CXXFLAGS = +ifdef KCPP_DEBUG + CFLAGS = -g -O0 + CXXFLAGS = -g -O0 +endif +CFLAGS += -I. -Iggml/include -Iggml/src -Iinclude -Isrc -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_LLAMAFILE +CXXFLAGS += -I. -Iggml/include -Iggml/src -Iinclude -Isrc -I./common -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c++11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_LLAMAFILE +ifndef KCPP_DEBUG + CFLAGS += -DNDEBUG -s + CXXFLAGS += -DNDEBUG -s +endif + +#lets try enabling everything +CFLAGS += -pthread -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-variable +CXXFLAGS += -pthread -Wno-multichar -Wno-write-strings -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-variable + LDFLAGS = FASTCFLAGS = $(subst -O3,-Ofast,$(CFLAGS)) FASTCXXFLAGS = $(subst -O3,-Ofast,$(CXXFLAGS)) @@ -69,10 +84,6 @@ OBJS_FULL += ggml-alloc.o ggml-aarch64.o ggml-quants.o unicode.o unicode-data.o OBJS_SIMPLE += ggml-alloc.o ggml-aarch64.o ggml-quants_noavx2.o unicode.o unicode-data.o sgemm_noavx2.o common.o sampling.o grammar-parser.o OBJS_FAILSAFE += ggml-alloc.o ggml-aarch64.o ggml-quants_failsafe.o unicode.o unicode-data.o sgemm_failsafe.o common.o sampling.o grammar-parser.o -#lets try enabling everything -CFLAGS += -pthread -s -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-variable -CXXFLAGS += -pthread -s -Wno-multichar -Wno-write-strings -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-variable - # OS specific # TODO: support Windows ifeq ($(UNAME_S),Linux) diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp index 342042ffb..8ce4add1b 100644 --- a/examples/llava/clip.cpp +++ b/examples/llava/clip.cpp @@ -1108,7 +1108,7 @@ struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) { } } - clip_ctx * new_clip = new clip_ctx; + clip_ctx * new_clip = new clip_ctx{}; // update projector type {