diff --git a/src/emacs-module.c b/src/emacs-module.c index 0abfd3f6f1..4f2b0ecd4b 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -458,6 +458,8 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, return lisp_to_value (env, result); } +static bool my_check = false; + static emacs_value module_funcall (emacs_env *env, emacs_value fun, ptrdiff_t nargs, emacs_value args[]) @@ -473,6 +475,7 @@ module_funcall (emacs_env *env, emacs_value fun, ptrdiff_t nargs, xsignal0 (Qoverflow_error); SAFE_ALLOCA_LISP (newargs, nargs1); newargs[0] = value_to_lisp (fun); + my_check = EQ (newargs[0], Qfile_name_as_directory); for (ptrdiff_t i = 0; i < nargs; i++) newargs[1 + i] = value_to_lisp (args[i]); emacs_value result = lisp_to_value (env, Ffuncall (nargs1, newargs)); @@ -581,8 +584,10 @@ module_make_string (emacs_env *env, const char *str, ptrdiff_t length) /* FIXME: AUTO_STRING_WITH_LEN requires STR to be null-terminated, but we shouldn't require that. */ AUTO_STRING_WITH_LEN (lstr, str, length); - return lisp_to_value (env, - code_convert_string_norecord (lstr, Qutf_8, false)); + Lisp_Object lisp = code_convert_string_norecord (lstr, Qutf_8, false); + eassert (STRINGP (lisp) && SSDATA (lisp)); + my_check = true; + return lisp_to_value (env, lisp); } static emacs_value @@ -955,6 +960,8 @@ value_to_lisp_bits (emacs_value v) static Lisp_Object value_to_lisp (emacs_value v) { + bool b = my_check; + my_check = false; if (module_assertions) { /* Check the liveness of the value by iterating over all live @@ -972,7 +979,11 @@ value_to_lisp (emacs_value v) { Lisp_Object *p = XSAVE_POINTER (XCAR (values), 0); if (p == optr) - return *p; + { + if (b) + eassert (STRINGP (*p) && SSDATA (*p)); + return *p; + } ++num_values; } ++num_environments; @@ -1008,6 +1019,8 @@ lisp_to_value_bits (Lisp_Object o) static emacs_value lisp_to_value (emacs_env *env, Lisp_Object o) { + bool b = my_check; + my_check = false; if (module_assertions) { /* Add the new value to the list of values allocated from this @@ -1020,6 +1033,11 @@ lisp_to_value (emacs_env *env, Lisp_Object o) ATTRIBUTE_MAY_ALIAS emacs_value ret = vptr; struct emacs_env_private *priv = env->private_members; priv->values = Fcons (make_save_ptr (ret), priv->values); + if (b) + { + eassert (STRINGP (o) && SSDATA (o)); + eassert (STRINGP (*optr) && SSDATA (*optr)); + } return ret; }