Aspose PDF Deadlock

Hello,

We’re having a deadlock situation on our build server and it appears to be an Aspose.PDF function. Can you help me understand what may be calling this obfuscated function so that we can add a semaphore to our code to avoid the deadlock please.

Version 24.10.0
Aspose.PDF.dll
#=zRMa686ULsLO_QU4901d4ezMbY54XnN_cOA==.#=zC$AYVqBrvSsC8HNeKA==.#=z85t6ABy9Oox4xelhkJF5m$I=()

image.jpg (125.7 KB)

Thank You,
-Andy

I forgot to mention that this issue began recently after upgrading Aspose dll’s. It’s possible that this deadlock was introduced recently.

Thank You,
-Andy

@weissa
Please provide more information so that we can try to reproduce the scenario and reproduce issue.
It would be great if you could provide a code snippet that reproduces the issue.

This is important information. Could you establish more precisely, starting from which version this began to manifest itself? Because if it is not possible to reproduce the problem, this may be the only clue.

@sergei.shibanov,

Since the issue is happening on our CI server and it’s a deadlock, it’s very difficult to get a stack trace. I do have a .dmp file of the process that is about 1 gig in size that I can make available to you privately if you wish.

Dev tools showed that the function: #=z85t6ABy9Oox4xelhkJF5m$I=()
in class: #=zC$AYVqBrvSsC8HNeKA==
contains a Monitor which appear to be where the deadlock is occurring.

A customer of ours who upgraded logged a case in our support desk complaining that one of their automated tasks which produces 200 PDF files is hanging and required a restart. I’m working to reproduce the issue and get a .dmp file to determine confirm that it’s the same deadlock issue.

I have verified that downgrading Aspose.PDF to 24.9.0 resolves the issue on our build server, so it appears that the deadlock was introduced in 24.10.0

As I learn more I will share.

Thank You,
-Andy

@sergei.shibanov,

24.9.0 is also exhibiting the deadlock on our build server. Here is an updated screenshot showing the deadlock with 24.9.0

image.png (20.5 KB)

-Andy

@weissa
Since the problem will be difficult to reproduce, it is advisable to determine which version of the library it started with (stacktrace will also give a clue). Try to determine this by linking it to the license operation date. What license do you have, how do you install it - has anything changed in this?

@sergei.shibanov,

I have reproduced the issue. We were setting the Aspose PDF license in the constructor of one of our services, which meant that we might call SetLicense while another thread is creating a document. It seems that if you call SetLicense while also creating a new Document, a deadlock may occur. This is easy for us to workaround.

   [Test]
    public async Task foo65()
    {
        var options = new ParallelOptions() { MaxDegreeOfParallelism = 20 };
        var numbers = Enumerable.Range(0, 1000);
        Parallel.ForEach(numbers, options, number =>
        {
            var asposeLicense = new License();
            asposeLicense.SetLicense("Aspose.Cells.lic");

            var doc = new Document();
        });
    }

Thank You,
-Andy

@weissa
It’s great that the reason has been found and thank you for your feedback.