W3wp hangs and the cpu usage goes to 100%

Hello,
we have a problem when we extract pages from PDF. Our code is this:

Using msInput As New MemoryStream(Me.m_Content)
  Dim doc As Aspose.Pdf.Document = Nothing
  doc = New Aspose.Pdf.Document(msInput)

  Using doc
	' Se la pagina di partenza è maggiore del numero di pagine totali allora sollevo l'ezzezione
	If pageToExtract > Me.PagesNumber Then
	  Throw New ArgumentOutOfRangeException("start", "Il valore eccede il numero massimo di pagine")
	End If

	Using s As New MemoryStream
	  Dim pngDevice As New Aspose.Pdf.Devices.PngDevice(New Aspose.Pdf.Devices.Resolution(160))
	  pngDevice.Process(doc.Pages(pageToExtract), s)
	  Return s.ToArray
	End Using
  End Using
End Using

Normally everything works fine. Some customers are reporting to us that sometimes the web server cpu goes to 100%. In the last case we took the dump and from the report we notice several threads blocked. This is the .NET call stack:

mscorlib_ni!System.Collections.Generic.Dictionary2[[System.Char, mscorlib],[System.__Canon, mscorlib]].FindEntry(Char)+90 mscorlib_ni!System.Collections.Generic.Dictionary2[[System.Char, mscorlib],[System.__Canon, mscorlib]].TryGetValue(Char, System.__Canon ByRef)+17
#=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zUyEVsg0=(System.String, Int32)+53
#=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zBB44TLZkhfZO()+23956
#=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zLosKcq_WNF7h(System.String)+58
#=zSqzusIrgJAILlW0lx8UB_DZW9N$AZoN4sMcjuiZB4CdUjGTCja6IGR8=.#=zfFGJuckqeX5w(Int32, Boolean, #=zmsuYlit2oG9Gnzwt8qpla4RTbx6Y ByRef)+2ed
#=zSqzusIrgJAILlW0lx8UB_DZW9N$AZoN4sMcjuiZB4CdUjGTCja6IGR8=.#=zFl1h_L_E6vj5iq0tDg==(#=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==, Boolean, #=z0LKTtC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)+914
#=zQORx9pydK3jnPNBcTf45ytdm6rrf.#=z$iAGxIw=()+15
Aspose.Pdf.Devices.ImageDevice.#=z$iAGxIw=(Aspose.Pdf.Page)+9a
Aspose.Pdf.Devices.PngDevice.Process(Aspose.Pdf.Page, System.IO.Stream)+18
itConsult.joshProtocol.DocumentsManager.DocumentRasterizer.ExtractPage(Int32, Int32)+119
itConsult.joshProtocol.Services.DocumentoWCFService.getDocumentoTotalPages(itConsult.joshProtocol.Entities.Documento)+e5
itConsult.joshProtocol.Services.DocumentoWCFService.OpenDocumentForViewer(Int32, Int32)+b11
DynamicClass.SyncInvokeOpenDocumentForViewer(System.Object, System.Object[], System.Object[])+d8
System_ServiceModel_ni!System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(System.Object, System.Object[], System.Object[] ByRef)+2c1
System_ServiceModel_ni!System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(System.ServiceModel.Dispatcher.MessageRpc ByRef)+1a6
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(System.ServiceModel.Dispatcher.MessageRpc ByRef)+ab
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(System.ServiceModel.Dispatcher.MessageRpc ByRef)+147
System_ServiceModel_ni!System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean)+12d
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext, Boolean, System.ServiceModel.OperationContext)+643
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext, System.ServiceModel.OperationContext)+1ca
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult)+49
System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump()+f82233
System_ServiceModel_Internals_ni!System.Runtime.IOThreadScheduler+ScheduledOverlapped.IOCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+54
System_ServiceModel_Internals_ni!System.Runtime.Fx+IOCompletionThunk.UnhandledExceptionFrame(UInt32, UInt32, System.Threading.NativeOverlapped*)+3a
mscorlib_ni!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+7f
[[GCFrame]]
[[DebuggerU2MCatchHandlerFrame]]
[[ContextTransitionFrame]]
[[DebuggerU2MCatchHandlerFrame]]

The report warning is this:

Multiple threads enumerating through a collection is intrinsically not a thread-safe procedure. If the dictionary object accessed by these threads is declared as static then the threads can go in an infinite loop while trying to enumerate the dictionary if one of the threads writes to the dictionary while the other threads are reading\enumerating through the same dictionary. You may also experience High CPU during this stage.

We cannot replicate the problem, so we don’t know under what circumstances it occurs.
Is it possible to have feedback from you? Have you already been notified of a similar problem? From the information we have given you, can you figure out what the cause could be?

Thanks.

@itconsult.developer

Unfortunately, it is difficult to say what the problem is without document and code example. To reproduce the issue, we need the sample code example and PDF document. So, please create a sample application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As we have indicated above, it is not possible to create a sample app where to replicate the problem. It not depends on specific PDFs. The problem occurs in customer environments after hours of work and in particular situations.

What we were asking was if, by analyzing the NET call stack, you could figure out what your internal function was involved and under what circumstances it could happen.

Unfortunately we cannot provide any other details, as we do not have any. We were asking you for more information.

@itconsult.developer

We have logged this issue as PDFNET-51007 in our issue tracking system. Once there is any update available on it, we will let you know.

Hello,
is there any news on this item? My manager also purchased paid support and if necessary I will open a ticket there.
Thanks.

@itconsult.developer

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

You reported this issue in free support forum and it will be treated with normal priority. To speed up the progress of issue’s resolution, we suggest you please check our paid support policies from following link.
Paid Support Policies