Comments (14)
Is there an efficient and reliable way to do this? Continuing after handling an asynchronous signal can leave the system in an inconsistent state.
from julia.
OK, the only thing I can think of is to block SIGINT around anything that temporarily violates invariants.
from julia.
Either that or set a flag and check it at various safe checkpoints. This is not just a repl issue: any "real" programming langage needs to be able to trap and handle signals reliably. Maybe we can look into how other languages handle this.
from julia.
There is no shortage of debate around asynchronous signals (e.g. FPE, SEGV, INT). Everybody wants to trap them and handle them gracefully but POSIX simply won't let you do it. Of course everybody does it anyway and it usually works.
Setting a flag is one of the safer approaches, but it isn't good enough. If we want to be able to break out of "while true end" then we have to check the flag before every backward branch.
from julia.
Would blocking signals during the critical sections (i.e. when the process could be left in an incoherent state) solve the problem? Doing some reading, it seems that POSIX signals sent while signals are blocked should be delivered immediately after the signals become unblocked.
from julia.
Maybe. We have relatively few places that do non-atomic updates to global state, but I would worry about library calls like malloc().
This technique looks like a good way to deal with this with low overhead:
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC375
We could wrap malloc with this, but a user might still call the native malloc.
We could at least protect julia's internal state to avoid serious corruption. And we could provide a macro like @sigatomic for user code. I think we'd have to use it in several places in multi.j since the scheduler has global state.
Ultimately these things can't really be left up to the language, because users need to decide if and how they will handle signals, and what kind of overhead they are willing to accept.
from julia.
Can we provide our own malloc so that users and libraries can't call libc malloc directly?
Agreed that you have to let users decide ultimately, but the default should be safe first, and hopefully also with relatively little overhead. The @sigatomic macro is an excellent addition. Most people will never have to use it, but we can provide the ability, which is key.
from julia.
Safe yes, but against what? Handling signals is not part of most applications' normal operation. I hate to add overhead just for the 1 time a week you want to hit ctrl-C, but I guess it can't be helped and hopefully won't even be measurable.
I don't think we should bother much about what external native code does, since realistically you're not going to be able to make everything safe.
I glanced at the ruby source, and it seems to use the same trick I linked to above, with critical sections around various things in the code.
from julia.
Ruby handles these things well, whereas Perl, for example is notoriously bad at it (although fast).
from julia.
I think it is important to architect the system for ctrl-c. It's a real pain in the cloud environment, if you are in a native code computation, and ctrl-c just doesn't become effective. I would even be ok with leaking memory, as a user. I used to frequently want to hit ctrl-c when using Star-P, and it was really painful as it just didn't do anything useful.
Also, I don't think ctrl-c should quit the client. That is what ctrl-d does.
from julia.
Agree --- even though I don't really believe in ctrl-c, it's one of those perceptual things that people expect and just feels nice.
Parallel ctrl-c is certainly interesting. We could use ssh to remotely run kill -SIGINT of a hung julia process.
from julia.
This issue seems adequately addressed to me at this point. Can we close it?
from julia.
We probably need more signal-atomic sections. I haven't dealt with malloc, free, and realloc, and task switching, and who knows, maybe more. It's annoying though because all those sigatomic sections are like lisa simpson's tiger-repelling rock; you can't really be sure it's working.
from julia.
It's annoying though because all those sigatomic sections are like lisa simpson's tiger-repelling rock; you can't really be sure it's working.
Brilliant analogy.
from julia.
Related Issues (20)
- 1.10 regression involving a higher-order function calling `^` HOT 1
- sysimage-native-code=no option broken
- Stack overflow during type inference of `LinuxPerf` in VSCode REPL HOT 1
- REPLCompletions spends a lot of time on `statx` syscalls (when crawling filesystem) HOT 15
- Round to Nearest Fraction HOT 3
- Bounds check outside loop affects loop performance
- `fieldcount` and `fieldtypes` mishandle some `Union` types HOT 3
- Regression in broadcast assignment to a `SlowSubArray` on nightly HOT 1
- Julia should have Pointers and Rust-like segmentation fault Analysis in compile time If ALLAH gives permission
- `Iterators.cycle`, `IteratorSize`: infinite but empty iterator HOT 1
- more source-build problems, with openblas now on CI HOT 9
- REPL does not have StyledStrings in its dependencies HOT 8
- Add error hint for `append(::Vector{String}, ::String)`
- make error message for Union{} arguments more accurate
- constructing tuples: some reasonable `Union` tuple type constructors throw
- constructing a tuple from an iterator may fail when it's not supposed to HOT 1
- return type infers worse than allowed by type assertion
- Add gerneric function for lazy `PermutedDimsArray` or `permutedims` keyword HOT 6
- `resize!(x,...)` not working after `y = x * A[1:1, :]` HOT 3
- [FR] provide a public API for accessing/mapping over `Union` components HOT 7
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 julia.