I have trouble with my thesis document. The sidebar table of contents (when opening in a pdf viewer) has a wrong ordering. Even though chapter 1 and chapter 2 are on the same hierarchical plane in the sidebar pdf toc chapter 2 is under chapter 1 (and chapter 3 and all other chapters are under chapter 2).

The normal table of contents in the document is fine. I think it has something with bookmarks (which I'm not 100% sure what they are).

After I fix a mistake in my latex document and latex doesn't compile fully. The next compile ends with the error:

 Runaway argument?

 

{\376\377\0002\000.\0005\000.\0001\000\040\000R\000o\000t\000a\000t\0\ETC. ./thesis.tex:293 (which is \begin{document}: File ended while scanning use of \@@BOOKMARK. 

trashing the aux file clears that and the next compile is fine again (the ordering of the pdf toc is still messed up).

How do I debug that? I can't really disable packages as they are tightly integrated. Any suggestions are welcome.

-
There is a missing parenthesis in a macro where its contents is also set as a bookmark. However, I suppose yor thesis will be printed. Why do you then need hyperref? – Herbert Aug 16 '11 at 9:07

The bookmarks are the things in the sidebar. The runaway error probably maens that one of your \chapter etc command does contains something which breaks when hyperref tries to put it in the bookmark. Inspect the aux and the out-file. Perhaps you can find the culprit. Or put \end{document} in the middle of your document and then move it around until you find the point where the error appears.
You can try to protect fragile commands with \protect\gls.... Or use \texorpdfstring: tex.ac.uk/cgi-bin/texfaq2html?label=texorpdf – Ulrike Fischer Aug 16 '11 at 10:30