Crash with `pointer being freed was not allocated` in SNUnit
Opened this issue · 1 comments
lolgab commented
I didn't try yet to reproduce on a smaller example.
Non-minimal reproduction
// server.sc
//> using platform "scala-native"
//> using lib "com.github.lolgab::snunit::0.2.4"
//> using lib "com.github.lolgab::snunit-async-epollcat::0.2.4"
//> using lib "com.armanbilge::epollcat::0.1.2"
import snunit._
AsyncServerBuilder
.build(_.send(StatusCode.OK, "Hello!", Seq.empty))
#!/bin/bash
scala-cli package -f server.sc
curl --unix-socket /usr/local/var/run/unit/control.sock -XPUT -d '
{
"applications": {
"app": {
"type": "external",
"executable": "./server",
"limits": {
"requests": 2
}
}
},
"listeners": {
"*:8082": {
"pass": "applications/app"
}
}
}
' http://localhost/config
how to run
# in a terminal with pwd on the same dir where server.sc is
unitd --log /dev/stdout --no-daemon
# in another terminal
./deploy.sh
curl localhost:8082/hello
curl localhost:8082/hello
curl localhost:8082/hello
After the third request we receive the quit_t event from NGINX Unit which should make the process end gracefully and make Unit create a new one, but with epollcat I get this log in NGINX Unit:
server(68567,0x113118600) malloc: *** error for object 0x7f94df808200: pointer being freed was not allocated
server(68567,0x113118600) malloc: *** set a breakpoint in malloc_error_break to debug
And then it doesn't respond anymore.
The server behaves normally with scala-native-loop
armanbilge commented
This is the only call to free
in epollcat.
epollcat/core/src/main/resources/scala-native/socket.c
Lines 63 to 64 in 911d61e
So it's not really obvious to me what's going on :)