Description: Trying to insert a citation from Zotero using the LibreOffice Zotero integration causes a spinning wheel to appear. LibreOffice is then hung and must be force quite. Zotero is also hung and must be force quit. Steps to Reproduce: 1. This starts with a specific type of .odt document which must contain a bookmark. 2. Try inserting a citation to a Zotero reference just after the bookmark. The cursor will turn to the spinning ball and LibreOffice must be force quit as must Zotero. 3. Actual Results: Pop up of the citation search and insertion bar. Expected Results: Spinning wheel and hang. Reproducible: Always User Profile Reset: Yes Additional Info: LibreOffice version 24.2.3.2 (AARCH64) does this. version 7.6.7.2 (AARCH64) does not. Zotero version 7.0.0-beta.77+adaa61f2c Zotero LibreOffice Integration 6.0.3 MacOS 14.2.1 I can provide a test file if needed. Since this depends on the extension, a safe mode test will not work here.
Created attachment 194079 [details] test030.odt This file does not cause the spin and hang, but does not allow the integration to work. Attempting to insert a citation just does nothing. This is likely related. I have a much larger file which causes the hang, but thought I should submit this smaller one first.
I don't know anything about Zotero, but my first guess is that LibreOffice is caught in a deadlock between two competing threads. Are you familiar with the Activity Monitor application on macOS? If yes, can you upload a sample of LibreOffice when it is hanging? If no, I can write some steps for you.
Created attachment 194103 [details] Sample file while spinning is occurring.
Thank you for the sample. From your sample, it looks like LibreOffice might be stuck in loop. I am not very familiar with the Writer code, but from what I can see, during your sample Writer was busy creating a list of all of the chunks of text in your document. The loop is called from Java code so I wonder if the Zotero extension is reconstructing the entire document. So, can you trigger the hang again and, this time, wait a full minute before taking a sample. This will tell us if we are still in the same loop after a minute has passed or if the looping is elsewhere.
This is a regression from 7.6.7.2. We at Zotero have not investigated what specifically in our extension causes it, but we can if that would help with fixing this.
Created attachment 194116 [details] Sample of spinning LibreOffice after one minute As requested, this is a sample of the LibreOffice process which has been spinning for one minute after attempting to activate the Zotero insert/edit citation command. In this case, Zotero also required a force quit afterwards.
I will also add a bit more detail here that was also covered in the discussion at Zotero at https://forums.zotero.org/discussion/114299/bug-macos-libreoffice-crash-on-insert-citation#latest As noted here as well, this does not occur with LibreOffice version 7.6.7.2 for the same test files. It only occurs if one tries to insert the citation right after a bookmark entry in the .odt document. If one removes the bookmark, the problem goes away.
Your latest sample is in the same exact bit of code in the lcl_ExportBkmAndRedline() function as it was in your previous sample. So, I think LibreOffice is blocked and waiting for something (reading a file or network connection?) somewhere in the lcl_ExportBkmAndRedline() function. I will see if I can somehow find the LibreOffice source code line that matches the memory address in the sample where LibreOffice is stuck.
Created attachment 194120 [details] File which does not spin because bookmark is removed. I just decided to recheck this. test030.odt does cause the spin. test031.odt, which I just attached and has only the single bookmark in the file removed, does NOT cause the spin. Since the spin does not happen with LibreOffice version 7.6 but does with 24.2.3.2, this suggests to me that a change in the code around the point identified in the samples or perhaps before in the parsing and analysis of the bookmarks in the document is causing either LibreOffice to send something which violates the protocol for Zotero or exposes a bug in that protocol on the Zotero end. The fact that Zotero also is hung and requires a force quit tends toward the latter explanation I think.
(In reply to Peter N. Steinmetz from comment #9) > Created attachment 194120 [details] > File which does not spin because bookmark is removed. > > I just decided to recheck this. test030.odt does cause the spin. > test031.odt, which I just attached and has only the single bookmark in the > file removed, does NOT cause the spin. Interesting. I was installing the following and just tested both test030.odt and test031.odt in LibreOffice version 24.2.3.2 (AARCH64) to match your setup. Zotero beta is newly installed so I can only select My Library > Unfiled Items > Zotero Quick Start Guide when I click the Add/Edit toolbar button in Writer: Zotero version 7.0.0-beta.77+adaa61f2c Zotero LibreOffice Integration 6.0.3 If I put the cursor at the beginning of the paragraph starting with "To simulate", click on the Add/Edit toolbar button, select "Zotero Quick Start Guide" in the Zotero popup window, and press enter, a citation gets inserted in both documents. The only thing that I have different than you is that I am running macOS Sonoma 14.4.1. Is there anything else that I am doing differently than you?
Thanks for looking into that Patrick. Yes, very important. You have to place the insertion point just before '{\Numpy version'. That is right after the bookmark. The bookmark is not visible which made this a dickens to isolate.
(In reply to Peter N. Steinmetz from comment #11) > Thanks for looking into that Patrick. Yes, very important. You have to place > the insertion point just before '{\Numpy version'. That is right after the > bookmark. > > The bookmark is not visible which made this a dickens to isolate. Ahah! I can now reproduce the hang with test030.odt with the above steps and it is hanging in the exact same place as your sample. In my local master build, LibreOffice crashes instead of hanging so I will start debugging that crash first.
OK. I found what is triggering this bug: it is the following XML snippet in test030.odt's content.xml: <text:bookmark text:name="__DdeLink__4354_2143787274" /> If I select the View > Navigator menu item and delete this bookmark, no crash in my local master build and no hang in LibreOffice 24.2.3. So Writer definitely gets stuck in an apparently infinite loop. The only difference in my local master build is that, instead of looping, I enabled debug code and so it crashes when it hits the following assertion: Assertion failed: (!"Some bookmarks were not consumed earlier"), function lcl_ExportBookmark, file unoportenum.cxx, line 611. I am not familiar with the code, so I will need to step through the code and see if I can find where the above bookmark derails the exit from the loop.
Nice find Patrick. I also found that if I removed that tag from the xml and reconstructed the document that the problem went away. Definitely sounds like something in the parser is broken. I wonder if it has to do with the tag just being and open and close tag, with an attribute but no content?
A few more hints. It will still spin after deleting that bookmark and inserting another one with a different name. It spins if you try to insert the citation anywhere AFTER the bookmark, but not before it.
(In reply to Adomas Venčkauskas from comment #5) > This is a regression from 7.6.7.2. We at Zotero have not investigated what > specifically in our extension causes it, but we can if that would help with > fixing this. I think I found a fix for this "stuck in an infinite loop" bug. Does Zotero do LibreOffice builds internally? If yes, you can test out my fix by applying the following patch to either a master of libreoffice-24-2 branch build: https://gerrit.libreoffice.org/c/core/+/167710
This *might* be related to commit 1d7ce421480d9170316533de03feb8d04eb5c767 and/or commit 58e79c4394783033f61e1309214d9060e2f0adf2.
https://gerrit.libreoffice.org/c/core/+/167720 is my blind take (I *hope* I see the problem that I introduced in commit 1d7ce421480d9170316533de03feb8d04eb5c767, from the code reading - I didn't repro the specific problem here).
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/9d3c6b31158aedc33bd616981f0f80af8a0ed1b0 tdf#161035: The previous bookmarks can legitimately be not processed It will be available in 24.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-24-2": https://git.libreoffice.org/core/commit/324c1a72961ccc1af1c496689c558aa127ef3d81 tdf#161035: The previous bookmarks can legitimately be not processed It will be available in 24.2.4. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike Kaganski's fix for this bug should be in tomorrow's (17 May 2024) nightly master builds: https://dev-builds.libreoffice.org/daily/master/current.html Note for macOS testers: the nightly master builds install in /Applications/LibreOfficeDev.app. These builds are not codesigned like regular LibreOffice releases so you will need to execute the following Terminal command after installation but before you launch /Applications/LibreOfficeDev: xattr -d com.apple.quarantine /Applications/LibreOfficeDev.app
Daily build for aarch64 is not working on my system so I can't test. I guess I will wait for 24.8.0.
Sorry, I guess I can't delete the prior comment, but I see the remark in the email about permissions.