Commit graph

7357 commits

Author SHA1 Message Date
Marius Gerbershagen
3ec7c3b749 threading: fix race conditions when interrupted while pushing in the stack
We have to make sure that the stack pointers always point to a
    valid object. This means that we have to increase env->stack_top
    before we change things in the stack.
2018-02-04 21:53:45 +01:00
Marius Gerbershagen
276f4c79ff threading: save/restore more environment elements in handle_all_queued to prevent race conditions
env->stack_top has to be temporarily increased too, to prevent
    it from being overwritten from the interrupting code.
2018-02-04 21:26:08 +01:00
Marius Gerbershagen
b92f30d263 threading: use safer allocation method for interrupt_struct in _ecl_alloc_env 2018-02-03 22:45:33 +01:00
Marius Gerbershagen
11f495f2b3 threading: restore env->function in handle_all_queued
If a thread is interrupted directly after a call to
    ecl_function_dispatch, env->function may be overwritten before
    it is used. Thus we need to save and restore when we
    execute queued signals.
2018-02-03 22:29:04 +01:00
Marius Gerbershagen
1beabdf9a2 threading: fix ecl_import/release_current_thread
Due to the recent changes introduced in ECL_WITH_SPINLOCK_BEGIN,
    we need a functioning environment when we use this macros.
2018-02-02 20:00:24 +01:00
Marius Gerbershagen
e458caf652 threading: fix barrier implementation
The logic im mp_barrier_wait is wrong. decrement_counter returns
    the value of the counter __before__ it is decremented. Before
    the fix, the counter decremented until it reached 0 and then the
    next arriving thread would get stuck in decrement_counter. Also,
    interrupts were not reenabled in all cases.
2018-01-26 20:56:16 +01:00
Marius Gerbershagen
6449d67337 threading: prevent deadlock in ecl_get_spinlock if we already own the lock 2018-01-22 21:58:40 +01:00
Marius Gerbershagen
3946e2031f threading: lock signal_queue_spinlock in queue_signal with the right thread 2018-01-22 21:56:46 +01:00
Marius Gerbershagen
34ca2a2f38 threading: fix newly introduced race condition in mp_process_enable
If mp_process_enable is interrupted after pthread_create, but
    before its exit code is examined, the cleanup code may be run
    even when pthread_create did not fail, so we need to disable
    interrupts in this region.
2018-01-22 21:52:25 +01:00
Marius Gerbershagen
79b77fc7e5 add another forgotten ecl_enable_interrupts 2018-01-22 21:13:07 +01:00
Marius Gerbershagen
30a4e64c97 fix typo in ecl_clear_interrupts_env() 2018-01-22 21:11:24 +01:00
Marius Gerbershagen
1265ab111a threading: add error message for forgotten ecl_enable_interrupts 2018-01-22 21:11:24 +01:00
Marius Gerbershagen
5b28a8fc1f threading: make sure that spinlocks are unlocked
If a thread is killed while it holds a spinlock, the lock will
    never be released, leading to deadlocks. Hence we have to clean
    up spinlocks in ECL_WITH_SPINLOCK_END. In mp_process_enable,
    other cleanup (deallocating the environment, unlisting the
    process) has to performed too.
2018-01-22 21:08:34 +01:00
Marius Gerbershagen
ba8b85fc22 make sure interrupts are enabled again after having been disabled
This is important to prevent race conditions. If interrupts are
    left disabled, the environment may be wrongly write protected by
    an interrupting thread and completely harmless writes in the
    environment can lead to segmentation faults.
2018-01-14 20:26:15 +01:00
Marius Gerbershagen
6316012408 fix race condition when a process during cleanup is interrupted too early by a call to mp_exit_process
If a process, that has already unwound its whole frame stack
  (after ECL_CATCH_ALL_END in thread_entry_point) is interrupted by
  a call to mp_exit_process, ECL will crash with a segmentation
  fault. We thus need to aquire the start_stop_spinlock before we
  unwind the frame stack.
2018-01-07 16:31:40 +01:00
Marius Gerbershagen
f5a503c862 fix segmentation faults when a signal is queued for a thread whose environment is write protected
If a thread is interrupted while interrupts are disabled by C,
    then the signal is queued and the environment is write protected
    by mprotect. If another thread then calls queue_signal, it will
    try to write in the protected environment, leading to a
    segmentation fault. Since mprotect can only protect whole memory
    pages, we need to allocate the pending interrupts and the signal
    queue in a separate struct.
2018-01-06 17:58:59 +01:00
Marius Gerbershagen
9227f4e342 fix #409: order of evaluation of values forms
the fix for #330 is unaffected
2017-12-29 16:58:27 +01:00
Marius Gerbershagen
39000946e3 bytecmp: Make sure that load time forms are applied in the correct order. Fixes #312 2017-12-19 21:13:11 +01:00
Daniel Kochmanski
2e9c58b3d4 mulithreading: fix semaphore-signal
It didn't wake up all processes to check the condition what caused n+1 lag in
condition check for signal-process (when called with n>1). Fixes #421. No
regression test, because this is already tested in sem-signal-* tests (they were
failing).
2017-12-08 13:40:34 +01:00
Daniel Kochmanski
a51f28f6a5 tests: improve some fail explanations, add last-fail var 2017-12-08 13:40:34 +01:00
Daniel Kochmanski
5bb14d94c7 cosmetic: add ignore declaration
see #16.
2017-12-08 13:40:34 +01:00
Daniel Kochmański
fead4ce858 Merge branch 'develop' into 'develop'
Fix for #292

See merge request embeddable-common-lisp/ecl!97
2017-12-08 07:23:29 +00:00
Marius Gerbershagen
31ed58b7c3 add regression test for #292 2017-12-02 22:08:39 +01:00
Marius Gerbershagen
a0a1a54747 don't check type declarations for default values of optional and keyword function arguments
almost all other implementations do the same, so we should also
allow this edge case
2017-12-02 21:49:46 +01:00
Daniel Kochmański
21f0b92fdd Merge branch 'develop' into 'develop'
New documentation: small update

See merge request embeddable-common-lisp/ecl!96
2017-11-28 19:41:24 +00:00
Tomek Kurcz
f34938c506 Port the porting ECL section from the old doc 2017-11-25 13:00:47 +01:00
Tomek Kurcz
5116a13ebc Port the interpreter section from the old doc 2017-11-25 12:55:46 +01:00
Tomek Kurcz
de5e28ccac Update status.org for the new documentation
Some things that are actually written already weren't ticked in the
TODO list.
2017-11-25 12:36:51 +01:00
Marius Gerbershagen
80ced3c9b1 add test for #418 2017-11-21 18:00:25 +01:00
Marius Gerbershagen
2f48a7df9d loop.lsp: remove wrong type declaration for on keyword. Fixes #418 2017-11-21 17:59:20 +01:00
Daniel Kochmański
d2fc77d4f9 Merge branch 'develop' into 'develop'
Fix #410 link error as feenableexcept not present on OSX.

Closes #410

See merge request embeddable-common-lisp/ecl!95
2017-11-05 10:10:45 +00:00
Marius Gerbershagen
c279138bb2 bytecmp.lisp: allow T for :output-file in bc-compile-file. Fixes #393 2017-11-03 20:29:09 +01:00
Fabrizio Fabbri
45722f06c9
Fix #410 link error as feenableexcept not present on OSX. 2017-10-23 00:40:37 -04:00
Daniel Kochmanski
e45b808aa8 help: add documentation for posix threads (process module) 2017-10-11 10:55:43 +02:00
Daniel Kochmanski
92206c1704 help: update open doc 2017-10-11 10:27:10 +02:00
Daniel Kochmanski
e42d95d41a cosmetic: some indent fixes 2017-10-11 10:27:01 +02:00
Daniel Kochmanski
a7e376c0b5 process: use newly added interface make-stream-from-fd 2017-10-11 10:26:30 +02:00
Daniel Kochmanski
c771b46c5f feature: export make-stream-from-fd interface 2017-10-11 10:25:59 +02:00
Daniel Kochmanski
05871c943a fix debugging leftover 2017-10-09 22:56:32 +02:00
Daniel Kochmanski
835e85bc99 cleanup: remove dead code block
if x length is < 5, reader will signal an error, so it will never be
equal 2. Probably a leftover from some previous bytecodes
implementation state.
2017-10-09 22:51:52 +02:00
Daniel Kochmanski
9ba7440782 bytecmp: be smart wrt bytecompiled code
bytecompiled functions may not have a name (i.e lambda assigned to
smothing). Recognize that fact, so when we read back such functions
from file we can call bc-compile on them. Fixes #313.
2017-10-09 22:45:50 +02:00
Daniel Kochmanski
b851e85701 cosmetic: line unwrap 2017-10-09 22:45:38 +02:00
Daniel Kochmanski
21f670894a run-program: fix typo 2017-10-09 10:15:21 +02:00
Daniel Kochmanski
a42d199b6a run-program: move t->stream coercion at the beginning
this is important for piping.
2017-10-09 10:01:19 +02:00
Daniel Kochmanski
e329d5bb49 tests: fix test for non-thread builds 2017-10-09 09:47:50 +02:00
Daniel Kochmanski
b00b15b078 external-process: use locks only when threads are enabled 2017-10-09 09:38:26 +02:00
Daniel Kochmanski
3d7f68445b changelog: add run-program changes 2017-10-09 09:36:05 +02:00
Daniel Kochmanski
3c4e374feb tests: run-program: enable tests for virtual streams 2017-10-09 09:36:02 +02:00
Daniel Kochmanski
3043dac56b ext:run-program: implement virtual streams for input/output/error 2017-10-09 09:35:59 +02:00
Daniel Kochmanski
2a98ce10fe core: si:copy-stream has three arguments
argument `wait' denots, whenever we wait for EOF or yield when there
is no input available in the first stream.
2017-10-09 09:35:54 +02:00