Commit graph

6595 commits

Author SHA1 Message Date
Daniel Kochmański
ca0962cdb3 Printer addresses 2018-05-04 08:38:33 +00:00
Marius Gerbershagen
07391b9ced reader: be more ANSI compliant with *read-suppress*
We should not signal an error if we don't find a dispatch macro
    character and *read-suppress* is true. The following example from
    the CLHS documentation on *read-suppress* wrongly signaled an
    error:
      (let ((*read-suppress* t)) (read-from-string "#\garbage"))
    Fixes #431.
2018-04-24 22:42:10 +02:00
Marius Gerbershagen
7955a36b08 reader: signal different error when not finding an external symbol
Most other implementations signal a reader-error instead of a
    simple-error. Closes #438.
2018-04-24 21:28:41 +02:00
Marius Gerbershagen
58c5316ece bytecmp: Unify behaviour of nested eval-when forms with native compiler
The current behaviour may technically be ANSI compliant, but it
    differs from the behaviour of the native compiler and from many
    other Common Lisp implementations (sbcl, ccl, clisp, abcl and cmucl).
2018-04-21 18:14:28 +02:00
Marius Gerbershagen
b00e62f9d3 cmp: Allow for compile time evaluation of inlined forms
The following statement:
    (eval-when (:compile-toplevel :load-toplevel :execute)
      (print "test"))
    resulted in an error, since the compiler would expand the print
    statement in a FFI:C-INLINE form, which can't be evaluated at
    compile time.
2018-04-21 15:34:20 +02:00
Marius Gerbershagen
825c8d2b2e doc: Add section for C compiler configuration options
Closes #218.
2018-04-09 22:23:25 +02:00
Daniel Kochmanski
399b2357a1 remove unused function 2018-04-09 07:53:41 +02:00
Daniel Kochmanski
2c52e278cc Don't ensure GF in method macroexpansion time
Fixes #46.

Also some cosmetic fixes and test fix.
2018-04-08 21:05:37 +02:00
Daniel Kochmanski
28d245631e tests: add class-forward-reference regression test (fixed in last commit) 2018-04-08 11:09:11 +02:00
Daniel Kochmanski
ead9ab4f38 validate-superclass: return T when class is a forward-referenced-class
defclass calls indirectly ensure-class-using-class from builtin module which
calls make-instance on metaclass (which could be a forward-referenced
class). That triggers validate-superclass on

  (validate-superclass #<forward-ref-class> #<standard-class standard-object>)

which failed. This commit mitigates this situation. Problem was masked
because of *clos-boot* never been set to T (recently fixed).
2018-04-08 10:56:50 +02:00
Daniel Kochmanski
7f1bb5c59b tests: add two regression tests 2018-04-06 17:51:33 +02:00
Daniel Kochmanski
98f29d34b9 clos: don't allow subclassing builtin classes
This issue was discussed at some point in the past. See
https://gitlab.com/embeddable-common-lisp/ecl/issues/426 for some logs.

Fixes #426.
2018-04-06 17:36:06 +02:00
Daniel Kochmanski
d641c39bd9 clos: invalidate initarg caches when new methods are defined
Closes #425. Fix contributed by Bike from #clasp.
2018-04-06 16:36:36 +02:00
Daniel Kochmanski
3fd005d8df run-program: fix loop in pipe-stream
When we have called something like this

    (ext:run-program "true" nil :wait nil :output *standard-output*)

pipe-stream were running in a loop until someone has called
external-process-wait (or external-process-status). This was a hogging the
processor without a reason. Right now unless some other wait is already called
checks for the process status (and magically removes zombies).

Also always call sleep (not thread-yield), because this loop eats a lot of cpu
otherwise.
2018-04-06 15:56:15 +02:00
Daniel Kochmanski
59f74fc4be run-program: virtual streams: ensure that pipes are empty
After child has terminated we may still have something in pipes to copy. When
pipe-streams loop finishes check active pipes for data.
2018-04-06 13:37:54 +02:00
Daniel Kochmanski
17ce8c98d8 cosmetic: add some barebones comments and docs for bytecmp 2018-04-06 11:03:14 +02:00
Daniel Kochmański
297c4e4250 Merge branch 'develop' into 'develop'
Various changes

Closes #433

See merge request embeddable-common-lisp/ecl!102
2018-04-06 05:54:56 +00:00
Marius Gerbershagen
158cb84715 doc: fix makeinfo invocation failures
Some versions of makeinfo are quite strict about input files and
    don't allow whitespace between @macros and braces or nodes which
    are not referenced in some menu.
2018-04-04 21:27:11 +02:00
Marius Gerbershagen
dcfc987d81 fix wrong encodings reported by ext:all-encodings
:UCS-4LE was not in the list of basic encodings and the keywords
    for other encodings were mistakenly interned in lower
    case. Reported and fixed by Robert Dodier. Fixes #435.
2018-04-04 21:23:14 +02:00
Marius Gerbershagen
b8df7a777c cmp: execute cleanup forms of unwind-protect with interrupts disabled
Unifies behaviour with ECL_UNWIND_PROTECT.
2018-03-27 19:03:03 +02:00
Marius Gerbershagen
55d6367b6c cmp: add blocks around ecl_frs_push in generated C code
Avoids redefinition of __ecl_frs_push_result if e.g. two tagbodies
    follow each other in the same C block. This redefinition is an
    error in C and compilers will not accept the generated code.
2018-03-27 18:49:23 +02:00
Marius Gerbershagen
7b5361613b fix memory leak with bignums
Letting the gmp library use uncollectable allocations leads to
    leaks, if the bignums are not freed with mpz_clear. Since this
    can't be done without a finalizer, we have to use the standard
    allocation mechanism. Fixes #433.
2018-03-26 22:00:55 +02:00
Marius Gerbershagen
1b0ffbe6cc threading: fix race condition in mp_process_enable
Local variables were not declared volatile, so they could be
    changed by the setjmp call in ECL_UNWIND_PROTECT_BEGIN. This could
    lead to execution of the cleanup statements even though the thread
    creation was successfull and thus to segmentation faults.
2018-03-26 22:00:55 +02:00
Marius Gerbershagen
b9c4c3fc90 tests: add stress test suite 2018-03-26 21:11:30 +02:00
Marius Gerbershagen
146b4a6ae1 cosmetic: fixed some typos and style issues 2018-03-26 21:11:11 +02:00
Marius Gerbershagen
9fe9334538 fix rounding error in ecl_stack_set_size
The size of the arguments stack would grow quadratically, instead
    of being rounded to the nearest bigger page size.
2018-03-23 21:57:45 +01:00
Daniel Kochmański
7bfa7e37b6 Merge branch 'develop' into 'develop'
docs: fix a typo in a code example

See merge request embeddable-common-lisp/ecl!101
2018-03-16 15:09:02 +00:00
Daniel Kochmański
c09256866f Merge branch 'threading-fixes' into 'develop'
Threading fixes

Closes #419

See merge request embeddable-common-lisp/ecl!100
2018-03-16 15:08:27 +00:00
Kris Katterjohn
ae2d5e98a3 new-doc: fix a typo in a sffi code example
This changes the incorrect keyword :on-liner to the
correct :one-liner
2018-03-12 15:25:28 -05:00
Marius Gerbershagen
eca39581a5 fix build failures with --disable-threads 2018-03-02 18:56:23 +01:00
Marius Gerbershagen
d87c5b2c5a threading: fix resource leak on windows
Thread handles were never closed. Also fixed the ugly hack in
    process->thread, where a pthread_t object was used on windows instead
    of the correct HANDLE object.
2018-02-28 21:20:06 +01:00
Marius Gerbershagen
fd900d9c64 threading: fix race conditions in ecl_unlist_process/thread_cleanup
ecl_unlist_process is called in thread_cleanup after interrupts have
    been disabled, however it uses unwind-protect, which will disenable and
    then reenable interrupts. Since on windows, we don't have an equivalent
    of sigmask, we can't use unwind-protect and instead rely on disabled
    interrupts to make sure, that the spinlock is always released.
2018-02-28 20:55:49 +01:00
Marius Gerbershagen
47029db7b2 threading: fix race conditions on windows
ecl_check_pending_interrupts is used in ecl_enable_interrupts_env,
    which may not always be in a place where we can handle signals without
    safety measures. _ecl_w32_exception_filter needs to be protected too. Here,
    the switch statement could also fall through to EXCEPTION_INT_DIVIDE_BY_ZERO,
    leading to wrong errors being displayed.
2018-02-24 14:31:44 +01:00
Marius Gerbershagen
2ccc5de365 rename function arguments to avoid collision with identically named define
Fixes mingw build error.
2018-02-23 20:33:51 +01:00
Marius Gerbershagen
a8d7305fb6 threading: fix race condition in stacks_scanner
The garbage collector can call stacks_scanner in a thread before
    pthread_setspecific, leading to a wrong error message. The
    solution is simply not to mark the environment, if
    pthread_setspecific has not yet been called.
2018-02-20 21:40:04 +01:00
Marius Gerbershagen
f9630fa8b3 threading: fix race conditions in CLOS cache
If a thread is interrupted after a call to fill_spec_vector, but
    before it can call ecl_search_cache, the cache may change during
    the interrupt, leading to crashes. We can't use
    env->disable_interrupts since fill_spec_vector calls methods which
    write in the thread-local environment. Disabling interrupts in
    ecl_search_cache and clear_list_from_cache is now redundant and
    has been removed.
2018-02-20 20:24:08 +01:00
Marius Gerbershagen
25ec43b498 fix typo in stacks.h 2018-02-20 20:15:31 +01:00
Marius Gerbershagen
7d6112d0e8 threading: fix race condition in pop_signal
The pending interrupts list may be modified after we have checked
    whether it is nil, but before we aquire the spinlock, leading to
    segmentation faults.
2018-02-18 21:03:07 +01:00
Marius Gerbershagen
24e4c13d58 threading: block interrupts during execution of cleanup forms in unwind-protect
If we don't do this, execution of the cleanup forms may be
    interrupted or they may not be executed at all. This behaviour
    would probably be acceptable for external code, however the
    unwind-protect mechanism is also used internally to protect
    against deadlocks (e.g. in ECL_WITH_(SPIN)LOCK).
2018-02-18 21:02:26 +01:00
Marius Gerbershagen
3f0fc4f855 threading: fix race conditions in ECL_WITH_GLOBAL_ENV_RD/WRLOCK
We can't use ecl_disable_interrupts, because often writes in the
    thread local environment happen while we hold the locks (e.g.
    env->packages_to_be_created is written in find_pending_package
    while the lock is held in ecl_make_package). Therefore we use the
    lisp interrupt blocking mechanism. For this, the order of
    operations in cl_boot has to be modified a bit.
2018-02-18 21:01:44 +01:00
Marius Gerbershagen
e5281a4685 threading: add explanation about stack interrupt safety 2018-02-17 20:58:49 +01:00
Marius Gerbershagen
2193e4b55d fix typo in frs_set_size 2018-02-17 19:13:34 +01:00
Marius Gerbershagen
f0506f511e threading: fix possible race conditions in ecl_wakeup_waiters
Checking process.phase without holding the start_stop_spinlock
    looks dangerous, the thread may exit after the check but before we
    interrupt it. Also, we can't call mp_process_kill while interrupts
    are disabled, so we have to use the lower level ecl_interrupt_process.
2018-02-17 16:24:38 +01:00
Marius Gerbershagen
0ecea9487c move ECL_STACK_RESIZE_DIS/ENABLE_INTERRUPTS in a separate header file
Compilation of lisp files will sometimes fail otherwise, since
    .eclh files can include internal.h
2018-02-16 20:53:59 +01:00
Marius Gerbershagen
bad90d0f65 threading: safer handling of overflows in frame and binding stacks
Previously, the dummy tag was written behind the stack
    boundary. Also added race condition protection to non-inlined
    ecl_bds_bind/push. The memory barriers have been reworked,
    too. AO_store_full has been replaced by AO_full_nop. This is
    sufficient to insert the required memory barrier instructions and
    is implemented in a simpler way by libatomic_ops in some cases.
2018-02-16 19:58:20 +01:00
Marius Gerbershagen
fc29c08d93 threading: use safer method to disable interrupts when resizing stacks
Due to the use of mprotect() for fast interrupt dispatch it is
    not possible to write in the thread local environment when
    interrupts are disabled. We need to use sigprocmask to block
    interrupts in this case.
2018-02-16 19:07:27 +01:00
Daniel Kochmanski
17645d703e bytecodes cosmetic cleanup 2018-02-15 13:50:51 +01:00
Daniel Kochmanski
e92cfdf437 Unify compilation environment markers
In both bytecmp and c compiler we use si:function-boundary and
si:unwind-protect-boundary where appropriate. Previously bytecmp used an ad-hoc
special variable for function-boundary and didn't mark unwind-protect at all.

Remove recently-introduced ECI package (maybe we will reintroduce it later when
we'll have a common frontend for compilers).
2018-02-15 12:44:49 +01:00
Marius Gerbershagen
8a68a5c225 threading: fix race condition in ecl_unwind
If ecl_unwind is interrupted with another call to ecl_unwind
    before it has decremented env->frs_top, the second call of
    ecl_unwind may stop too early with its unwinding, leading to
    potential segfaults.
2018-02-14 22:52:22 +01:00
Marius Gerbershagen
e7838e4b86 threading: fix race conditions in CLOS cache
Writes in the cache were not protected against interrupts, leading
    to segfaults when clear_list_from_cache or ecl_search_cache were
    interrupted.
2018-02-14 20:41:58 +01:00