Raymond Toy pushed to branch master at cmucl / cmucl
Commits: e9a598e5 by Raymond Toy at 2018-02-19T08:41:07-08:00 Complex array accessors are not foldable
Fixes #61 and #62.
The `ARRAY-HAS-FILL-POINTER-P` and `ARRAY-DISPLACEMENT` functions are declared inline and the compiler tries to constant-fold these inlined functions operating on simple arrays.
Thus don't allow the compiler to constant-fold calls to `%ARRAY-FILL-POINTER-P`. This is normally protected by a call to `ARRAY-HEADER-P`, but when it's inlined, the compiler tries to constant-fold `%ARRAY-FILL-POINTER-P` on an array without such a slot.
Likewise `ARRAY-DISPLACEMENT` calls `%ARRAY-DISPLACED-P`, `%ARRAY-DATA-VECTOR`, and `%ARRAY-DISPLACEMENT`, and the calls are protected by `ARRAY-HEADER-P`. So don't constant-fold these either.
Maybe we could also make CONSTANT-FOLD-CALL be smarter about this?
* src/compiler/generic/objdef.lisp * Remove flushable from these ref-trans methods. * src/general-info/release-21d.md * Update * tests/issues.lisp * Add tests from the bug reports.
- - - - - ac4b9fc8 by Raymond Toy at 2018-02-19T16:50:47+00:00 Merge branch 'rtoy-fix-61-62-not-flushable' into 'master'
Complex array accessors are not foldable
Closes #61 and #62
See merge request cmucl/cmucl!38 - - - - -
3 changed files:
- src/compiler/generic/objdef.lisp - src/general-info/release-21d.md - tests/issues.lisp
Changes:
===================================== src/compiler/generic/objdef.lisp ===================================== --- a/src/compiler/generic/objdef.lisp +++ b/src/compiler/generic/objdef.lisp @@ -252,29 +252,32 @@ :ref-known (flushable foldable) :set-trans (setf %array-fill-pointer) :set-known (unsafe)) + ;; Don't let these ref-trans to be constant-folded because these + ;; might get called on arrays that don't have these slots. (Because + ;; the lisp functions might be inlined.) (fill-pointer-p :type (member t nil) :ref-trans %array-fill-pointer-p - :ref-known (flushable foldable) + :ref-known (flushable) :set-trans (setf %array-fill-pointer-p) :set-known (unsafe)) (elements :type index :ref-trans %array-available-elements - :ref-known (flushable foldable) + :ref-known (flushable) :set-trans (setf %array-available-elements) :set-known (unsafe)) (data :type array :ref-trans %array-data-vector - :ref-known (flushable foldable) + :ref-known (flushable) :set-trans (setf %array-data-vector) :set-known (unsafe)) (displacement :type (or index null) :ref-trans %array-displacement - :ref-known (flushable foldable) + :ref-known (flushable) :set-trans (setf %array-displacement) :set-known (unsafe)) (displaced-p :type (member t nil) :ref-trans %array-displaced-p - :ref-known (flushable foldable) + :ref-known (flushable) :set-trans (setf %array-displaced-p) :set-known (unsafe)) (dimensions :rest-p t))
===================================== src/general-info/release-21d.md ===================================== --- a/src/general-info/release-21d.md +++ b/src/general-info/release-21d.md @@ -35,6 +35,8 @@ public domain. * ~~#59~~ Incorrect type-derivation for `decode-float` * ~~#60~~ The function `C::%UNARY-FROUND` is undefined * ~~#58~~ Bogus type error in comparison of complex number with `THE` form + * ~~#61~~ Segfault when compiling call to `ARRAY-HAS-FILL-POINTER-P` on bit vector constant + * ~~#62~~ Segfault when compiling `ARRAY-DISPLACEMENT` on a string constant * Other changes: * Improvements to the PCL implementation of CLOS: * Changes to building procedure:
===================================== tests/issues.lisp ===================================== --- a/tests/issues.lisp +++ b/tests/issues.lisp @@ -521,3 +521,17 @@ (let ((c9 (compile nil #'(lambda (x) (= (the (eql 1.0d0) x) #c(1/2 1/2)))))) (assert-false (funcall c9 1.d0)))) + +(define-test issue.61 + (:tag :issues) + ;; Verifies that the compiler doesn't segfault and that we return + ;; the correct value. + (assert-false + (funcall (compile nil '(lambda () (array-has-fill-pointer-p #*10)))))) + +(define-test issue.62 + (:tag :issues) + ;; Verifies that the compiler doesn't segfault and that we return + ;; the correct value. + (assert-false + (funcall (compile nil '(lambda () (array-displacement "aaaaaaaa"))))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/771fd903423d15380c445426f...
--- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/771fd903423d15380c445426f... You're receiving this email because of your account on gitlab.common-lisp.net.