Comments (10)
I got the segfault as well.
I edited src/conf/janetconf.h
to have:
#define JANET_EV_NO_EPOLL
and rebuilt janet
to reproduce with the code in the comment above.
I don't know how reliable the results are but I used rr
to record execution and then snooped around a bit using rr replay
.
This is the output I got around the report of a segfault:
Thread 2 received signal SIGSEGV, Segmentation fault.
0x00007f05b167366e in janet_stream_close_impl (stream=<optimized out>) at src/core/ev.c:349
349 JanetStream *last = janet_vm.streams[j];
I guess that's this line.
from janet.
I used "TCP Echo Server" example from README as the server and janet -e '(def c (net/connect "127.0.0.1" 8000)) (:write c "abc") (ev/sleep 1e10)'
as client.
The server gets stuck in a busy loop after the client sends some data.
Janet compiled with meson setup build && ninja -C build
.
0ff8f58 is the first bad commit.
The commit is quite big unfortunately.
Server strace before commit (fd=5 - connection socket):
<...>
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN}], 3, -1
<waits for data>
Server strace after commit (fd=5 - connection socket):
<...>
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN|POLLOUT}], 3, -1) = 1 ([{fd=5, revents=POLLOUT}])
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN|POLLOUT}], 3, -1) = 1 ([{fd=5, revents=POLLOUT}])
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN|POLLOUT}], 3, -1) = 1 ([{fd=5, revents=POLLOUT}])
<...>
From man poll
:
POLLIN - There is data to read.
POLLOUT - Writing is now possible.
Janet doesn't want to write anything to the socket, yet still waits for it to be writable. Poll immediately signals that it is writable, hence the busy loop.
from janet.
Found the issue, the problem is that passing a valid file descriptor to poll with events = 0 immediately returns with POLLHUP.
See https://groups.google.com/g/comp.unix.programmer/c/bNNadBIEpTo/m/G5gs1mqNhbIJ?pli=1 for a conversation and workaround.
from janet.
@czkz Thanks for that secondary repro, that seems to be a closely related issue with the poll backend. This is not fixed by a9b8f8e however
from janet.
With epoll=false
, the following code causes segmentation fault.
(import spork/sh)
(def devnull (sh/devnull))
(ev/spawn-thread (ev/write devnull "ok"))
Welcome to hell.
from janet.
The issue is the copying of streams between threads. There is some thread local (interpreter global) state that needs copying. This only exists for the poll implementation, though.
from janet.
This should be fixed for me as of 12630d3 - the issue was janet_unmarshal_stream didn't re-register the stream with the event loop.
from janet.
I built the latest commit with epoll=false
, and this issue can still be reproduced with the sample code above.
from janet.
Is the segfault still happening? The 100% cpu is not yet addressed
from janet.
At least, the segmentation fault is gone now. The 100% cpu usage is not gone, yet.
from janet.
Related Issues (20)
- Proposal: Terse Chained Indices HOT 19
- Reimplement `slurp` with `os/open`. HOT 28
- A way to read standard input in the background without `file/read` in a thread. HOT 4
- `each` macro improper behavior? HOT 8
- `if-let` breaks tail call optimization. HOT 6
- false branch of `if-let` doesn't report the correct call stack information. HOT 4
- `ev/select` should not resume a dead task. HOT 4
- `try` and `defer` break tail call optimization. HOT 4
- `(= @"update" @"update")` is `false`. HOT 3
- `ev/select` still revives fibers.... HOT 2
- option to unbundle docstrings and potential consequences HOT 8
- splicing into structs/tables HOT 2
- Disasm/asm doesn't round-trip for function with unused argument HOT 1
- eventloop/networking gets stuck on musl HOT 11
- Consider making `module/paths` a dynamic variable HOT 6
- Can it run on iOS? Thank you. HOT 3
- `os/strftime` doesn't respect environment variables. HOT 3
- Re-integrate jpm into janet HOT 42
- recent change kinda breaks lexical scope with multiple modules HOT 2
- How to switch off spork/sh/copy message? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from janet.