Ok, thanks a lot for your suggestions. It seems that the problem comes from
poly-org mode. I've followed the following steps (copy-paste from my notes,
sorry for the wording):

+ I double-check the version of org (9.5.2, ok) and I check the function
  =org-latex-export-to-pdf=. This is ok since the fix is there:
  #+begin_example
    (let ((outfile (org-export-output-file-name ".tex" subtreep)))
    (org-export-to-file 'latex outfile
      async subtreep visible-only body-only ext-plist
      #'org-latex-compile)))
  #+end_example

+ Same error as before when trying to asynchronously export: the =*Org Export
  Process*= buffer still gives ~Invalid read syntax: "#"~

+ However, I do these double-checks with my init file loaded. Contrary to ~emacs
  -Q~, when I use ~M-x toggle-debug-on-error~ no =*Backtrace*= buffer opens. I
  conclude that maybe something linked to my init file is interfering with the
  process, preventing the debugger to correctly capture the error.

+ I thus decide to remove everything from my init file (except ~(use-package
  org)~) and to try again. However, the issue is still there and the debugger
  does not detect it. I note that =poly-org= mode is still (automatically)
  loaded at startup, and I decide to use my other computer and to start with a
  brand new installation of emacs.

+ On this new emacs version, the only package I install is =org=, in order to
  get version 9.5.2. This time, it works: I am able to asynchronously export.

+ I have the impression that having =poly-org= mode installed could play a role
  in my problem. I thus decide to get the init file from my other computer and
  load it on my new installation of emacs, *except the =polymode= part*. And it
  actually works: I am able to asynchronously export.

+ As a final test, I include the =polymode= part of my init file, and restart
  Emacs. This time the asynchronous export process fails.

What I conclude from that (correct me if I am wrong): the issue should come from
=polymode= which, once installed, somehow modifies the standard org-export
function/process. I am going to report this issue on the polymode github.

Best,

MP

------- Original Message -------
On Tuesday, March 8th, 2022 at 3:51 PM, Sébastien Miquel <sebastien.miquel@posteo.eu> wrote:

M. Pger writes:
Thx for your answer. I've just upgraded org-mode (elpa way) and I am now using version 9.5.2.

Version 9.5.2 should indeed contain the fix I had in mind :

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c91271297dbbfc831874d7880343603881bdac9c

Unfortunately this does not work, I still end up with:

Invalid read syntax: "#"
Can you check that the right version of org-mode is picked-up, with
`describe-function` `org-latex-export-to-pdf`, find the function
definition by following the `ox-latex.el` link, and check that the
source contains the linked patch ?
I would like to try the alternative, i.e. disabling native-comp (for the export function I guess). Would you mind telling me how to do that?

`describe-function` should also tell you whether the function is
native compiled. If it is, you can temporarily 'uncompile' by
evaluating its source code. By disabling native compilation I meant as
a compile flag, if you've built emacs from source. I cannot find an
easy way to prevent native compilation of a single package/function.

--
Sébastien Miquel