Skip to content

100% cpu spinning on tool call, generastion cannot be aborted #2500

Description

@schmorp

When koboldcpp received this (possibly malformed) tool call from gemma-4, it goes into a 100% cpu spinning loop.

Output: <|tool_call>call:vim_replace_lines{buffer:1,expected_changedtick:2,line:1,new_lines:["use strict;","use warnings;","use Time::HiRes qw(sleep);","my $w = 40;","my $h = 20;","my $p = 20;","my $s = 0;","my @world = map { ' ' x $w } 1..$h;","sub draw {"," system('clear');"," print "Score: $s\n";"," print '=' x ($w+2)."\n";"," for (@world) { print "|$_\n"; }"," print '=' x ($w+2)."\n";", "}", "sub update {"," pop @world;"," my $l = ' ' x $w;"," if (rand() < 0.2) { substr($l, int(rand($w)), 1) = 'Y'; }"," unshift @world, $l;"," substr($world[-1], $p, 1) = 'S';", " return 0 if substr($world[-1], $p, 1) eq 'Y';"," $s++; return 1;","}", "system('stty cbreak raw -echo');","eval {"," while (1) {"," draw();"," if (select(STDIN, undef, undef, 0.1)) {"," my $k = ;"," if ($k eq 'a' && $p > 0) { $p--; }"," elsif ($k eq 'd' && $p < $w-1) { $p++; }"," elsif ($k eq 'q') { last; }"," }", " last unless update();", " }", "};","system('stty sane');","print "\nGame Over! Score: $s\n";"],old_lines:[" "],target:<|"|>oben<|"|>}<tool_call|>

gdb backtrace is not very helpful, but shows it spinning in python, the only thread active:

#0 frame_dealloc (f=0x7f1ea0211590) at /usr/local/src/conda/python-3.8.20/Objects/frameobject.c:430
#1 0x00007f2779113747 in _Py_DECREF (op=0x7f1ea0211590, lineno=4314, filename=0x7f2779202190 "/home/conda/feedstock_root/build_artifacts/python-split_1727717877616/work/Python/ceval.c") at /usr/local/src/conda/python-3.8.20/Include/object.h:478
#2 _PyEval_EvalCodeWithName (_co=, globals=, locals=locals@entry=0x0, args=args@entry=0x7f1e9c06a900, argcount=argcount@entry=0, kwnames=, kwargs=0x7f1e9c06a900, kwcount=, kwstep=1, defs=0x0, defcount=0, kwdefs=0x0, closure=0x7f2762b86c10, name=0x7f2777ab5a30, qualname=0x7f2777ab80f0) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:4314
#3 0x00007f277912161d in _PyFunction_Vectorcall (func=, stack=0x7f1e9c06a900, nargsf=, kwnames=) at /usr/local/src/conda/python-3.8.20/Objects/call.c:436
#4 0x00007f2779114936 in _PyObject_Vectorcall (kwnames=0x0, nargsf=, args=0x7f1e9c06a900, callable=0x7f2762b693a0) at /usr/local/src/conda/python-3.8.20/Include/cpython/abstract.h:127
#5 call_function (kwnames=0x0, oparg=, pp_stack=, tstate=0x5592bdc5d1c0) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:4963
#6 _PyEval_EvalFrameDefault (f=, throwflag=) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:3500
#7 0x00007f2779113711 in _PyEval_EvalCodeWithName (_co=, globals=, locals=locals@entry=0x0, args=args@entry=0x7f275c1819f8, argcount=argcount@entry=0, kwnames=, kwargs=0x7f275c1819f8, kwcount=, kwstep=1, defs=0x0, defcount=0, kwdefs=0x0, closure=0x7f275c18e520, name=0x7f2777ab59b0, qualname=0x7f2777ab82d0) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:4298
#8 0x00007f277912161d in _PyFunction_Vectorcall (func=, stack=0x7f275c1819f8, nargsf=, kwnames=) at /usr/local/src/conda/python-3.8.20/Objects/call.c:436
#9 0x00007f2779114936 in _PyObject_Vectorcall (kwnames=0x0, nargsf=, args=0x7f275c1819f8, callable=0x7f2762b250d0) at /usr/local/src/conda/python-3.8.20/Include/cpython/abstract.h:127
#10 call_function (kwnames=0x0, oparg=, pp_stack=, tstate=0x5592bdc5d1c0) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:4963
#11 _PyEval_EvalFrameDefault (f=, throwflag=) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:3500
#12 0x00007f2779113711 in _PyEval_EvalCodeWithName (_co=, globals=, locals=locals@entry=0x0, args=args@entry=0x7f1ea0246750, argcount=argcount@entry=0, kwnames=, kwargs=0x7f1ea0246750, kwcount=, kwstep=1, defs=0x0, defcount=0, kwdefs=0x0, closure=0x7f2762b86c10, name=0x7f2777ab5a30, qualname=0x7f2777ab80f0) at /usr/local/src/conda/python-3.8.20/Python/ceval.c:4298

pressing abort causes koboldcpp to print:

"Generation Aborted"

but it's not true, it's not aborted, it just keep spinning in a 100% cpu loop.

this is specific to this tool call. a lot of other tool calls worked fine.

"--jinja --jinjatools" was in effect to work around koboldcpp starting new kv contexts for every tool call otherwise.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions