Open esad opened 4 years ago
(I encountered this on 8.1.x, but now I upgraded to version 8.3.3-59-g5d6358244 and this still happens)
Pushed a fix for the clib
submodule. The engine destruction destroyed the timers that belong to the original OS thread rather than the engine. That is fixed. An open issue is what should happen with the timeout? Now a possible timeout does not apply to the engine and gets effectuated as the engine_next/2 return control to the original thread. That is sometimes good, notably if you use engines to communicate between threads, and sometimes bad (when dealing with an engine only supporting the current thread and optionally doing slow computations).
(Note that when engine_destroy/1
is removed, the process still crashes, I guess it's getting garbage collected?)
I'm not familiar with engines or http code enough (yet :-) so you may need to explain the question. Which timeouts are you referring to? The way I understand it is that engines have no timeouts (coroutines) but http handlers do. So when an engine is taking time and triggering a timeout, shouldn't it be destroyed from the outside, by some kind of http server watchdog thread?
Btw. I think this might be the same bug as reported in https://swi-prolog.discourse.group/t/http-engines-and-timeouts/1631
(Note that when
engine_destroy/1
is removed, the process still crashes, I guess it's getting garbage collected?)
Doesn't reproduce.
shouldn't it be destroyed from the outside, by some kind of http server watchdog thread?
That is not entirely clear. If the engine solely works for the involved HTTP handler, probably that would be best. Engines can also be used to share information between threads though and in that case you probably do not want it to be killed.
This issue has been mentioned on SWI-Prolog. There might be relevant details there:
https://swi-prolog.discourse.group/t/http-engines-and-timeouts/1631/4
Here's a minimal sample where an engine is created, queried and destroyed within the http handler:
When I request http://localhost:5000 now I get the following stacktrace:
LLDB dump: