Thread blocked when trying to convert docx to pdf

Hello,

I’m using Aspose words to convert docx to PDF. Here the code I’m using :

Document doc = new Document(inputStream);
// Remove paragraphs with @remove-line.
Node[] paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true).toArray();
for (Node paragraph : paragraphs) {
	if (paragraph.getText().trim().equals(REMOVE_LINE)) {
		paragraph.remove();
	}
}
SaveOptions so = SaveOptions.createSaveOptions(SaveFormat.PDF);
so.setMemoryOptimization(true);
doc.save(pOut, so);

Untill septembre I’m using aspose words 18.2 (4 years, I know!) and everything works fine. Then in september, I update Aspose words 22.7 and since then I regularly have all the threads that use aspose that end up crashing one by one.

The application can convert 5 documents at the same time, so 5 threads. In the following capture we see the number of logs generated for each thread. We realize that they are all blocking one after the other :
threads.png (123.6 KB)

By doing a heap dump, I could see that these 5 threads are all stuck in the exactly same place, in an Aspose class :

AsynchronousRenderingExecutor-1
  at com.aspose.words.zzYA7.zzWCN()Z (:177)
  at com.aspose.words.zzzN.remove()V (:98)
  at com.aspose.words.zzWyv.zzZvN(Lcom/aspose/words/zzMH;Z)V (:222)
  at com.aspose.words.zzWyv.zzGX(Lcom/aspose/words/zzMH;Lcom/aspose/words/zzWyv;)V (:298)
  at com.aspose.words.zzMH.zzYqQ(Lcom/aspose/words/zzWyv;)V (:396)
  at com.aspose.words.zzWyv.zzZvN(Lcom/aspose/words/zzMH;Lcom/aspose/words/zzWyv;)V (:261)
  at com.aspose.words.zzMH.zzXrf(Lcom/aspose/words/zzWyv;)V (:407)
  at com.aspose.words.zzWVg.zzYqQ(Lcom/aspose/words/zz6Y;)Z (:182)
  at com.aspose.words.zzWVg.zzZvN(Lcom/aspose/words/zz6Y;Lcom/aspose/words/zz6Y;Z)Z (:202)
  at com.aspose.words.zzYw3.zzWCS(Lcom/aspose/words/zz6Y;Z)Z (:81)
  at com.aspose.words.zzYw3.zzZvN(Lcom/aspose/words/zzzN;Lcom/aspose/words/zz6Y;Z)Z (:89)
  at com.aspose.words.zzWVg.zzWCS(Lcom/aspose/words/zzzN;Z)Z (:165)
  at com.aspose.words.zzWVg.zzYSQ(Lcom/aspose/words/zzYA7;Z)Z (:93)
  at com.aspose.words.zzWVg.zzWCS(Lcom/aspose/words/zzzN;Z)Z (:160)
  at com.aspose.words.zzWVg.zzYSQ(Lcom/aspose/words/zzYA7;Z)Z (:93)
  at com.aspose.words.zzWVg.zzYSQ(Lcom/aspose/words/zz6Y;Z)Z (:68)
  at com.aspose.words.zzWVg.zzYSQ(Lcom/aspose/words/zzvy;Z)Z (:50)
  at com.aspose.words.zzWSz.zzZvN(Lcom/aspose/words/zzvy;Z)V (Unknown Source)
  at com.aspose.words.zzWbE.zzWj1()Z (:979)
  at com.aspose.words.zzWbE.zzXml()Z (:843)
  at com.aspose.words.zzWbE.zzGX(Lcom/aspose/words/zzvy;IZZ)Z (:116)
  at com.aspose.words.zzWbE.zzZvN(Lcom/aspose/words/zzvy;IZZ)Z (:53)
  at com.aspose.words.zzX9I.zzYVE()Z (:104)
  at com.aspose.words.zzX9I.zzYSQ(Lcom/aspose/words/zzYXm;I)Z (:52)
  at com.aspose.words.zzX9I.zzWCS(Lcom/aspose/words/zzYXm;I)Z (:30)
  at com.aspose.words.zzXtG.zzZvN(Lcom/aspose/words/zzYXm;I)V (:191)
  at com.aspose.words.zzXtG.zzGX(Lcom/aspose/words/zzYXm;)V (:64)
  at com.aspose.words.zzW4k.zzZ9H(Lcom/aspose/words/zzYXm;)Z (:284)
  at com.aspose.words.zzW4k.zzXnx(Lcom/aspose/words/zzYXm;)Z (:232)
  at com.aspose.words.zzW4k.zzYan()V (:95)
  at com.aspose.words.zzW4k.zzXrf(Lcom/aspose/words/zzXca;)V (:53)
  at com.aspose.words.zzW8z.zzWbu(Lcom/aspose/words/zzMH;)V (:35)
  at com.aspose.words.zzX1S.zzXFp(Lcom/aspose/words/zzMH;)Z (:135)
  at com.aspose.words.zzZOV.zzWbu(Lcom/aspose/words/zzMH;)V (:438)
  at com.aspose.words.zzXZF.zz5K()V (:293)
  at com.aspose.words.zzg6.zzWqD()V (:95)
  at com.aspose.words.Document.updatePageLayout()V (:2278)
  at com.aspose.words.zzXEN.zzXVD()V (:43)
  at com.aspose.words.zzXgA.zzya(I)V (:59)
  at com.aspose.words.zzVTI.zzZOb(II)V (:249)
  at com.aspose.words.zzVTI.zzGX(Lcom/aspose/words/zzVTI;)V (:155)
  at com.aspose.words.zzVTI.zzZvN(Lcom/aspose/words/Node;Lcom/aspose/words/zzVTI;)V (:150)
  at com.aspose.words.zzVTI.zzAV(Lcom/aspose/words/Node;)V (:137)
  at com.aspose.words.Document.zzVUC()V (:1969)
  at com.aspose.words.Document.zzGX(Lcom/aspose/words/zzY6m;)Lcom/aspose/words/SaveOutputParameters; (:1941)
  at com.aspose.words.Document.zzZvN(Lcom/aspose/words/internal/zzW7Y;Ljava/lang/String;Lcom/aspose/words/SaveOptions;)Lcom/aspose/words/SaveOutputParameters; (:1035)
  at com.aspose.words.Document.zzZvN(Lcom/aspose/words/internal/zzW7Y;Lcom/aspose/words/SaveOptions;)Lcom/aspose/words/SaveOutputParameters; (:1104)
  at com.aspose.words.Document.save(Ljava/io/OutputStream;Lcom/aspose/words/SaveOptions;)Lcom/aspose/words/SaveOutputParameters; (:1094)

Code of the blocked method in class zzYA7:

    final boolean zzWCN() {
        for(zzzN var1 = (zzzN)this.zzXxe(); var1 != null; var1 = (zzzN)var1.zzR9()) {
            if (!var1.isEmpty()) {
                return false;
            }
        }

        return true;
    }

After restarting the application, I try to reconvert one of the failing document and it works, so it doesn’t seem related to the document to be converted.

  • infinite loop due to external condition?
  • concurrent access?

So, do you have an idea of the problem?

Thank you

Jérôme

@kehrmit

Thank you for your message. However, please attach the .docx files for which the error appears, we will analyze the problem and reply to you as soon as possible.

Hello,

Before convert docx into pdf, docx is generated by the application with customer data, so i don’t have it.

As I say in my first post, I restarted the build process from the same data and it worked fine. So there must be an external cause. But unfortunately with Aspose’s obfuscated code I can’t see what is being used.

I will looking in the heapdump if I found file stored in the memory!

Thanks

@kehrmit,

in this case, we will analyze the behavior of the library with your code on our own documents. In case you find a file in the heapdump, it would be nice if you send it. We will report the results of the analysis in this forum thread shortly.