win_flex.exe (and likely win_bison.exe) isn't concurrency safe

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: win_flex.exe (and likely win_bison.exe) isn't concurrency safe
Date: 2022-09-02 22:43:35
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


building PG with meson on windows I occasionally got weird errors around
scanners. Sometimes scanner generation would fail with

win_flex.exe: error deleting file C:\Users\myadmin\AppData\Local\Temp\~flex_out_main_2

sometimes the generated scanner would just be corrupted.

I was confused by only hitting this in local VM, not in CI, but after finally
hunting it down it made more sense:

It uses a temporary file name without any concurrency protection. Looks like
windows' _tempnam is pretty darn awful and returns a predictable name as long
as no conflicting file exists.

Our documentation doesn't point to winflexbison, but recommends using
flex/bison from msys. But I've certainly read about others using winflexbison,
e.g. [1] [2]. The flex/bison in 'chocolatey', which I've also seen referenced,
is afaics winflexbison.

Afaict the issue also exists in our traditional windows build - but I've not
seen anybody report this as an issue.

I started this thread to document the issue, in case developers using visual
studio are hitting this today.

It looks like a similar issue exists for the windows bison port:

I've not observed that failure, presumably because the window for it is much

For the meson build it is trivial to "address" this by setting FLEX_TMP_DIR to
a private directory (which we already need to deal with lex.backup), something
similar could be done for src/tools/msvc.

Unless we think it'd be better to just refuse to work with winflexbison?


Andres Freund



Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2022-09-02 22:45:15 Re: Backpatching nbtree VACUUM (page deletion) hardening
Previous Message Nathan Bossart 2022-09-02 22:26:06 Re: introduce bufmgr hooks