Subject: Re: bug#30106: Loading file /sources/emacs/lisp/emacs-lisp/ert.elc failed to provide feature `mod-test'

From: Eli Zaretskii <[email-masked]>
Date: Tue, 16 Jan 2018 20:10:49 +0200

> Date: Mon, 15 Jan 2018 21:55:33 +0300
> From: Jean Louis <[email-masked]>
> Cc: [email-masked]
> 
> I can see that 'make check' fails so:
> 
>   ELC      src/emacs-module-tests.elc
> Emacs module assertion: Module function called from outside the current Lisp thread
> /bin/sh: line 1:  6214 Aborted                 EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=/sources/emacs/test "../src/emacs" --module-assertions -batch --no-site-file --no-site-lisp -L ":." -f batch-byte-compile src/emacs-module-tests.el

Ah, that changes almost everything.  The test fails here:

  static void
  module_assert_thread (void)
  {
    if (!module_assertions)
      return;
    if (!in_current_thread ())
      module_abort ("Module function called from outside "  <<<<<<<<<<<<<<<
		    "the current Lisp thread");
    if (gc_in_progress)
      module_abort ("Module function called during garbage collection");
  }

And in_current_thread does this:

  static bool
  in_current_thread (void)
  {
    if (current_thread == NULL)
      return false;
  #ifdef HAVE_PTHREAD
    return pthread_equal (pthread_self (), current_thread->thread_id);
  #elif defined WINDOWSNT
    return GetCurrentThreadId () == current_thread->thread_id;
  #endif
  }

So either current_thread is NULL in your case, or pthread_equal
returns false.  Can you tell which one of these happens?