kontainapp / km

Kontain Monitor
http://kontain.app
Apache License 2.0
28 stars 5 forks source link

A thread being created while a gdb breakpoint fires can cause an assert #1799

Open paulpopelka opened 11 months ago

paulpopelka commented 11 months ago

We've seen this a few times:

not ok 286 gdb_nextstep(alpine_static): gdb next step test

(from function `assert_equal' in file bats-assert/src/assert.bash, line 91,

from function `wait_and_check' in file test_helper.bash, line 193,

in test file km-bats-7.alpine_static, line 483)

`wait_and_check $pid 0 # expect KM to exit normally' failed

start: 2023-09-24 09:07:55.608638501+00:00 gdb_nextstep(alpine_static): gdb next step test

--- Test script output:

Waiting for a debugger. Connect to it like this:

gdb -q --ex="target remote 658e987afffa:17285" /home/appuser/km/tests/gdb_nextstep_test.alpine.km

GdbServerStubStarted

09:07:57.219641 km_gdb_accept_connec 261 memchec Connection from debugger at 127.0.0.1

Average time 1695546477

09:07:57.511818 km_gdb_detach 435 memchec gdb client disconnected

Waiting for a debugger. Connect to it like this:

gdb -q --ex="target remote 658e987afffa:17285" /home/appuser/km/tests/clone_test.alpine.km

GdbServerStubStarted

09:07:59.337851 km_gdb_accept_connec 261 memchec Connection from debugger at 127.0.0.1

clone()

09:07:59.624655 km_gdb_set_thread_vc 1648 memchec Assertion `vcpu->state != IN_GUEST' failed: No such file or directory

-- values do not equal --

expected : 0

actual : 134

The test payload being run is the clone_test.c program.

The suggestion is that the new thread comes into existence and starts running while gdb thinks the payload is stopped. When gdb starts the threads going it discovers the thread is running.