nomarie has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to install a software called CUFTS on a Ubuntu virtual machine using these instructions: https://github.com/eanders/CUFTS-Install-Notes/blob/master/CUFTS.mediawiki . However, after installing the software and dependencies, Apache fails to restart. The message in the error log is Cache::FastMmap does not support threads. How can I fix this? Note that I'm quite new at this and am only sort of sure this is a Perl rather than a Ubuntu problem - if I am wrong please let me know and I will post elsewhere.

Replies are listed 'Best First'.
Re: Cache :: FastMmap
by BrowserUk (Patriarch) on Aug 19, 2015 at 01:27 UTC

      Some person says:

      Never used them myself, but [....] Cache::FastMmap says:
      [...] ensure multiple processes [...]
      so it should certainly be thread-safe.

      Meanwhile, Cache::FastMmap itself reports:

      Cache::FastMmap does not support threads.

      Which source do you think is most likely to be correct? :)

      To add some context and/or clarity... Looking at the source code, FastMmap.pm, one finds:

      sub CLONE { die "Cache::FastMmap does not support threads sorry"; }

      Searching perlmod for "CLONE" we find that this sub is called after a Perl thread is created.

      So Cache::FastMmap clearly declares itself to not support Perl threads and that error message appearing as reported seems to indicate that Perl inside of Apache is actually creating Perl threads.

      My experience is that Apache doesn't create Perl threads by default nor in the vast majority of configurations of Apache that I've run into.

      So my guess at a possible short route to resolving the problem would be to modify the Apache configuration to tell it to stop spawning threads.

      [ Aside:

      It has been a long time since I looked at mixing Apache, Perl, and threads. But I recall finding that Apache threading made use of Perl threads. That matches a pattern I had seen elsewhere when embedding Perl into a program that uses threads. I still believe that this pattern comes about from an understandable (unless you expect people to read and understands the docs) but unfortunate misunderstanding.

      If I were to embed Perl into a program that uses threads, I would very much not make use of Perl's threads. I'd certainly be at least tempted to build Perl w/o "thread support". "But how can you use Perl from threads if you build it without support for threads?" you ask.

      Building Perl with support for threads is about making it possible for Perl to create threads. Using Perl from threads doesn't require that at all. When embedding Perl for use from threads, you have two choices:

      First, you can use a single Perl interpreter instance (per process) and access that instance from as many threads as you like so long as only one thread at a time uses it.

      Second, you can build Perl with "MUTLIPLICITY" (see perlguts) and have as many instances of the Perl interpreter as you want in your process and each can be used from any threads so long as only one thread at a time uses it. You could choose to bind each instance of the interpreter to a specific thread. That means you don't have to worry about having locks barring simultaneous use of each interpreter instance, but that also means that each thread must pay the penalty of the memory required for a full instance of Perl. For some use cases, that will make sense.

      (In the first case, I would probably build Perl w/o MULTIPLICITY, though it should work even w/ MULTIPLICITY so long as you always pass in the same "context".)

      Note that even a Perl module that doesn't "support threads" would likely work fine in multiple Apache threads if Apache had not made the mistake of using Perl threads. Now, there are a few things that a Perl module could do that could break in such a scenario, but I find those things to be rather unlikely in a Perl module, especially one embedded in Apache.

      But fixing Apache threads to not use Perl threads is likely no small endeavor (not even counting the significant political/social tasks required). So this aside isn't particularly useful. Though, I hope some small number of people find it, to some extent, informative.

      ]

      - tye        

        My experience is that Apache doesn't create Perl threads by default nor in the vast majority of configurations of Apache that I've run into.

        You're probably right tye. I attempted to set up Apache once a long time ago and gave up almost immediately.

        It was late (2:30am) and the author is someone I associate with correct information; so I passed on the link to allow the OP to make up his own mind whether the information the thread contained was useful to him.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
        In the absence of evidence, opinion is indistinguishable from prejudice.
        I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

      Thanks, I have seen that, but I am already using Cache::FastMmap as was suggested there and it still doesn't seem to be working, and the replies there suggest that IPC::Mmap isn't viable either. Unless I'm missing something? (if so you'll probably need to spell it out - as mentioned, I'm quite new at this...)

Re: Cache :: FastMmap
by Ravenhall (Beadle) on Aug 19, 2015 at 17:51 UTC

    It sounds like you are using a Perl which was built with thread support. You can find this out with:

    perl -V | grep archname=

    or:

    perl -V | grep useithreads=

    In the first example, the archname usually indicates if it is a threaded Perl. On my threaded version of 5.10.0, I get:

    osname=linux, osvers=3.13.0-24-generic, archname=x86_64-linux-thread-multi

    In the second example, you are looking to see if useithreads is set to define. Again, from my threaded 5.10.0 install:

    useithreads=define, usemultiplicity=define

    Try installing a non-threaded Perl and set Apache to use that instead of the system Perl. How to do that is left as an exercise for the reader, as it is beyond the scope of the question. However, something like Plenv or Perlbrew can make that relatively painless.

      Try installing a non-threaded Perl and set Apache to use that instead of the system Perl.

      The instructions followed (https://github.com/eanders/CUFTS-Install-Notes/blob/master/CUFTS.mediawiki) mention mod_perl. So your suggestion should probably be changed to:

      Try installing a non-threaded Perl and rebuild Apache to use that instead of the system Perl.

      which might even be a major pain when Apache was obtained via "apt-get install ... apache2 ..." along with a ton of other packages, some of which come pre-configured to use the instance of Apache provided by apt-get.

      It sounds like you are using a Perl which was built with thread support.

      As I noted elsewhere, the problem appears to be that Perl threads are actually being created (presumably by Apache). Just having a Perl that supports the creating of threads should not be enough to cause the reported problems (as near as I can tell).

      - tye