uWSGI on ubuntu 18 suddenly fails when –never-swap specified

Rich B asked:

I use uWSGI on ubuntu 18 (18.04.5 LTS). Very recently this stopped working – I’d get this error on startup:

Fatal Python error: Cannot recover from MemoryErrors while normalizing exceptions.

Nothing had changed my side but the server was set to auto-upgrade. Running uwsgi as root worked, but as www-data (which is how I run it normally) failed.

After some trial and error it turned out that the --never-swap option was causing this – certainly when I removed that, it worked again.

So I can live with removing --never-swap, but I’d love to know why this happened. Is some new security feature preventing non-root users locking memory pages – that’s what the doc says this option does – uWSGI doc here.

My answer:

An unprivileged process needs the CAP_IPC_LOCK capability in order to lock memory pages. Most likely someone (you or another admin) set this capability manually, and then it was of course gone when a recent update was installed.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.