Skip to content

Commit 81bc921

Browse files
authored
train : fix #4227 (double free in examples/train-text-from-scratch/train-text-from-scratch.cpp) (#4351)
On commit b1108 (44c117f) xaedes added ggml_allocr * alloc = NULL; ... (many lines in between) if (alloc) { ggml_allocr_free(alloc); } Which is correct, but it's easy to lose context after many lines in between. On commit b1287 (0e76a899) xaedes made a big change. From here on, alloc is freed eagerly. alloc = ggml_allocr_new(...) ... (short lines of code) ggml_allocr_free(alloc) This happens a few times, but alloc is never set to NULL, and many lines below, we still have if (alloc) { ggml_allocr_free(alloc); } which causes a double-free.
1 parent 05cd6e5 commit 81bc921

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

examples/train-text-from-scratch/train-text-from-scratch.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,6 @@ int main(int argc, char ** argv) {
12951295
opt_cb_data.last_save_iter = opt->iter;
12961296
}
12971297

1298-
if (alloc) {
1299-
ggml_allocr_free(alloc);
1300-
}
1301-
13021298
ggml_free(opt->ctx);
13031299
free_train_state(train);
13041300
ggml_free(model.ctx);

0 commit comments

Comments
 (0)