unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#18065: guile hangs if strerror is called with invalid (non-int) argument
@ 2014-07-20 15:25 Glenn Michaels
  2014-08-01 19:47 ` Ian Price
  2014-11-12  6:05 ` Mark H Weaver
  0 siblings, 2 replies; 3+ messages in thread
From: Glenn Michaels @ 2014-07-20 15:25 UTC (permalink / raw)
  To: 18065

Calling strerror with a non-integer argument causes guile to hang.
e.g.:

(strerror 1.5)

It's a locking issue, which is solved by the following trivial patch:

--- a/libguile/error.c
+++ b/libguile/error.c
@@ -121,10 +121,12 @@ SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0,
 #define FUNC_NAME s_scm_strerror
 {
   SCM ret;
+  int errnum;
   scm_dynwind_begin (0);
+  errnum = scm_to_int (err);
   scm_i_dynwind_pthread_mutex_lock (&scm_i_misc_mutex);
 
-  ret = scm_from_locale_string (strerror (scm_to_int (err)));
+  ret = scm_from_locale_string (strerror (errnum));
 
   scm_dynwind_end ();
   return ret;





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18065: guile hangs if strerror is called with invalid (non-int) argument
  2014-07-20 15:25 bug#18065: guile hangs if strerror is called with invalid (non-int) argument Glenn Michaels
@ 2014-08-01 19:47 ` Ian Price
  2014-11-12  6:05 ` Mark H Weaver
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Price @ 2014-08-01 19:47 UTC (permalink / raw)
  To: 18065


Your patch does solve this issue, but I'm not 100% why the problem
occurs in the first place, as the lock should have been unlocked when
the throw occurred.

If I catch the wrong type error explicitly, then there is no problem.

scheme@(guile-user)> (catch #t (lambda () (strerror 1.5)) list)
$1 = (wrong-type-arg #f "Wrong type (expecting ~A): ~S" ("exact integer" 1.5) (1.5))

My thinking is that the a pre-unwind handler in the repl tries to lock
the same mutex, but I haven't looked into this deeply enough.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18065: guile hangs if strerror is called with invalid (non-int) argument
  2014-07-20 15:25 bug#18065: guile hangs if strerror is called with invalid (non-int) argument Glenn Michaels
  2014-08-01 19:47 ` Ian Price
@ 2014-11-12  6:05 ` Mark H Weaver
  1 sibling, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2014-11-12  6:05 UTC (permalink / raw)
  To: Glenn Michaels; +Cc: 18065-done

Fixed in fda17c20a3d088fccab1671c8881bd217d83d5f6 on the stable-2.0
branch, which will become Guile 2.0.12.

     Thanks,
       Mark





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-12  6:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-20 15:25 bug#18065: guile hangs if strerror is called with invalid (non-int) argument Glenn Michaels
2014-08-01 19:47 ` Ian Price
2014-11-12  6:05 ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).