Q:

LuaLaTeX engine, babel and pdfx package

There is one error with the combination of spanish babel, pdfx package, and LuaLaTex engine, how it is very easy to test with this MWE:
\documentclass{article}

\usepackage[spanish]{babel} 

\usepackage{amsmath}
\usepackage{pdfx}   

\begin{document}

\begin{equation*}
P_{\max}=0.1
\end{equation*}

\end{document}

The .log contains
!  Illegal unit of measure (pt inserted). 
<to be read again> 
/
l.11 P_{\max
          }=0.1
?  
!  Missing number, treated as zero. 
<to be read again> 
\xdef 
l.11 P_{\max
          }=0.1
?  
!  Illegal unit of measure (pt inserted). 
<to be read again> 
\xdef 
l.11 P_{\max
          }=0.1
?  
!  Illegal unit of measure (pt inserted). 
<to be read again> 
/
l.11 P_{\max
          }=0.1
?  
!  Missing = inserted for ifdim. 
<to be read again> 
/
l.11 P_{\max
          }=0.1
?  
!  Missing number, treated as zero. 
<to be read again> 
/
l.11 P_{\max
          }=0.1
?  

and a stream of similar complaints all for the same single line. 

A:

It's a bug in spanish, which has popped up after a change in pdfx.  As a workaround, after loading babel, write:
\makeatletter
\def\es@fetchenc{%
  \begingroup
    \count@\escapechar \escapechar=\m@ne
      \edef\es@a{\expandafter\string\the\textfont\mathgroup}%
      \expandafter\split@name\es@a////\@nil
    \escapechar=\count@
    \@expandtwoargs\in@{////}{\f@size}%
    \ifin@\else
      \PackageError{spanish}{%
        Non-NFSS font name.  The current math font (\es@a)\MessageBreak
        doesn't follow the NFSS conventions.  I'll use the\MessageBreak
        default \string\i\space for \string\dotlessi,
        but expect a wrong output.}%
      {Find where this font has been (re)defined, and fix it.}%
      \def\f@encoding{OT1}%
    \fi
  \bbl@exp{\endgroup\def\\\f@encoding{\f@encoding}}}
\makeatother

