mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
Fix possible deadlock upon encoding-error' in
open-input-string'.
Partly addresses <http://bugs.gnu.org/11197>. * libguile/strports.c (scm_mkstrport): Call `scm_port_non_buffer', set Z's cell type and stream, and release `scm_i_port_table_mutex' early. Reacquire `scm_i_port_table_mutex' once BUF, C_BUF, and STR_LEN are initialized. * test-suite/tests/ports.test ("string ports")["encoding failure leads to exception"]: New test.
This commit is contained in:
parent
ecb48dccba
commit
03fcf93bff
2 changed files with 39 additions and 7 deletions
|
@ -413,6 +413,22 @@
|
|||
(pass-if "output check"
|
||||
(string=? text result)))
|
||||
|
||||
(pass-if "encoding failure leads to exception"
|
||||
;; Prior to 2.0.6, this would trigger a deadlock in `scm_mkstrport'.
|
||||
;; See the discussion at <http://bugs.gnu.org/11197>, for details.
|
||||
(catch 'encoding-error
|
||||
(lambda ()
|
||||
(with-fluids ((%default-port-encoding "ISO-8859-1"))
|
||||
(let ((p (open-input-string "λ"))) ; raise an exception
|
||||
#f)))
|
||||
(lambda (key . rest)
|
||||
#t)
|
||||
(lambda (key . rest)
|
||||
;; At this point, the port-table mutex used to be still held,
|
||||
;; hence the deadlock. This situation would occur when trying
|
||||
;; to print a backtrace, for instance.
|
||||
(input-port? (open-input-string "foo")))))
|
||||
|
||||
(pass-if "%default-port-encoding is honored"
|
||||
(let ((encodings '("UTF-8" "UTF-16" "ISO-8859-1" "ISO-8859-3")))
|
||||
(equal? (map (lambda (e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue