opened
mkunes
username_0
When compiling the document below using `latexmk`, the compilation runs forever, because the `.bbl` file keeps changing:

In `\refsection{0}` of the `.bbl` file, the line `\keyalias{TestAlias}{TestSmith}` will only appear on the 1st, 3rd, 5th, etc. run of `biber`. On the 2nd, 4th, 6th, etc. run it is missing. This seems to only affect refsection 0 - for sections 1+ the command appears correctly. Something similar also happens in the `.bcf` file.

I've managed to resolve the issue by adding `\newrefsection` at the beginning of my document. But the behaviour still feels like a bug.

Tested with biber version 2.14 (fresh installation of TeX Live 2019). The same issue was also present in v2.10 (TeX Live 2017).

MWE:

```
\documentclass{article} 

\usepackage{filecontents}
\begin{filecontents*}{bibliography.bib}

@article{TestAuthor1,
	title={A Fake Paper},
	author={Author, A. and Advisor, B.},
	pages={7--8},
	year={2014}
}

@inproceedings{TestAuthor2,
	title={Another Fake Paper},
	author={Author, A. and Colleague, C.},
	booktitle={2016 Placeholder Conference on Citation Testing},
	pages={5--6},
	year={2016}
}

@inproceedings{TestSmith,
	title={This is a Test},
	author={Smith, John and Jones, Jane},
	booktitle={2016 Placeholder Conference on Citation Testing},
	pages={3--4},
	year={2016},
	ids={TestAlias},
}
\end{filecontents*}

\usepackage[backend=biber]{biblatex}

\addbibresource{bibliography.bib}

\DeclareBibliographyCategory{my_papers}
\addtocategory{my_papers}{TestAuthor1,TestAuthor2} 

\begin{document}
% \newrefsection % if I add this, everything works

\textcite{TestSmith}

\textcite{TestAlias}

\textcite{TestAuthor1}

\printbibliography

\newrefsection
\nocite{*}
\printbibliography[category=my_papers,title={Authored and Co-authored Publications}]

\end{document}
```
With \newrefsection, \keyalias commands for refsection 0 are missing from the bbl file on every 2nd run, resulting in an endless latexmk compilation
issue
created
plk
username_1
@username_2 - What is your opinion on this? The issue is that writing of aliases to the .bcf only happens in `\blx@endrefsection`. When there is an active >0 refsection at document close, the open refsection is closed automatically in `\AtEndDocument`. This means that refsection 0 is never closed and it's aliases are not written to the .bcf. This is basically a long-standing bug which really only appears with aliases as that's what are processed at the end of a refsection. Anything like this will result in refsection not being cleanly closed:

```
\begin{document}

...

\newrefsection

...

\end{document}

```
comment
created
moewew
username_2
I can't claim to have fully understood what is going on, but if this is only about refsections not ending cleanly, https://github.com/username_2/biblatex/commit/8b9ee045d31b0f3ae592c0a458871df709ae7bad be enough.

With that fix the MWE seems to work fine again.

@username_1 Let me know if you want me to merge this.
comment
created
plk
username_1
I think that this fix is fine - it's a long-standing issue that really only appear with section 0 aliases - let's merge it.
comment
created
moewew
username_2
OK. Merged https://github.com/username_1/biblatex/commit/8b9ee045d31b0f3ae592c0a458871df709ae7bad to dev.
comment
created
plk
username_1
Please try DEV version 3.15 (with biber 2.15 DEV) from Sourceforge.
comment
closed
mkunes
username_0
issue
created
mkunes
username_0
Yes, the new version works well, my project now compiles without issues. Thank you both!

(Also thanks for explaining what the actual cause was. Now I know that I can just replace the  `\newrefsection` with `\begin{refsection} ... \end{refsection}` and it will work even with older versions.)
comment