Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Dec 30, 2020 9:18 pm

I'm getting an "Attempted to read or write protected memory" exception when calling ApplyRecoveryString with the stack trace below.

The code extract is below. Any help appreciated.

Code: Select all
                bool blFirstRect = true;
                PdfPageBase page = pdfText.SearchPage;

                foreach (RectangleF rect in pdfText.Boundses)
                {
                    if ((blFirstRect)&&(strLabel!=" "))
                    {
                        pdfText.ApplyRecoverString(strLabel, colRedactColor, false);
                        blFirstRect = false;
                    }
                }


at System.Drawing.SafeNativeMethods.Gdip.GdipGetLogFontW(HandleRef font, HandleRef graphics, Object lf)
at System.Drawing.Font.ToLogFont(Object logFont, Graphics graphics)
at System.Drawing.Font.ToLogFont(Object logFont)
at System.Drawing.Font.ToHfont()
at spr⹸.ᜀ(Font A_0)
at spr⹸.ᜈ()
at spr⹸.ᜋ()
at Spire.Pdf.Graphics.PdfTrueTypeFont.ᜀ(Font A_0)
at Spire.Pdf.General.Find.PdfTextFind.ApplyRecoverString(String newvalue, Color backColor, Boolean unicode)
at GSRedactor.RedactTextBoundary(PdfTextFind pdfText, String strLabel) in W:\Source\source\Grain Silo\GrainSiloRedactor.cs:line 2752
at GSRedactor.RedactPDF(PdfDocument pdfSource, String strSourceFile, String strTargetFile, Dictionary`2 dictRedactees, List`1 listRedactShapes, List`1 listDeletedPages, RedactOptions roOptions, RedactMode rmMode, Boolean blRemoveOCR, Boolean blMinimizeFileSize, Int32 iFirstPage, Int32 iLastPage, String strWatermarkText) in W:\Source\source\Guardum\Grain Silo\GrainSiloEngine\GrainSiloRedactor.cs:line 1427
at GSRedactor.RedactPDF(String strSourceFile, String strTargetFile, Dictionary`2 dictRedactees, List`1 listRedactShapes, List`1 listDeletedPages, RedactOptions roOptions, RedactMode rmMode, Boolean blRemoveOCR, Boolean blMinimizeFileSize, Int32 iFirstPage, Int32 iLastPage, String strPassword, String strWatermarkText) in W:\Source\source\Guardum\Grain Silo\GrainSiloEngine\GrainSiloRedactor.cs:line 1151
at GSRedactor.RedactFile(String strSourceFile, String strTargetFile, Dictionary`2 dictRedactees, List`1 listRedactShapes, List`1 listDeletedPages, RedactOptions roOptions, RedactMode rmMode, Boolean blRemovePDFOCR, Boolean blMinimzeFileSize, Int32 iFirstPage, Int32 iLastPage, List`1 listExcelRanges, String strPassword, String strWatermarkText) in W:\Source\source\Guardum\Grain Silo\GrainSiloEngine\GrainSiloRedactor.cs:line 876
at ProcessRedactionProgress.RedactSARFile(Dictionary`2 dictSARFiles, String strFileName, String strArchiveFile, Dictionary`2 dictPersonalData, GSRedactor gsrRedactor, RedactOptions roRedactOptions, RedactMode rmRedactMode) in W:\Source\source\Guardum\Grain Silo\Guardum for TransPerfect\ProcessRedactionProgress.cs:line 552
at ProcessRedactionProgress.RedactorWorker(Object sender, DoWorkEventArgs e) in W:\Source\source\Grain Silo\4TP\ProcessRedactionProgress.cs:line 334
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Thu Dec 31, 2020 2:12 am

Hello,

Thanks for your inquiry.
I simulated a PDF file and tested your scenario, but did not reproduce your issue. To help us investigate further, please provide us with your input file. You could send it to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Dec 31, 2020 8:03 am

The issue doesn't seem to be file dependent, and it doesn't occur every time - It seems to be accumulative, which I know makes it difficult to investigate.

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Thu Dec 31, 2020 10:05 am

Hello,

Thanks for your response.
I discussed with our developers and learned that this issue should be related to a particular file. Could you please add some logs in the background to see which file was processed when the application threw the error? Then please provide the corresponding file to help us investigate further. Thanks in advance for your assistance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Jan 15, 2021 3:54 am

Hello,

Has your issue been resolved? If not, could you please provide your input PDF file to us for further investigation?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed May 05, 2021 8:56 pm

No, unfortunately, the issue still remains. The following are the latest examples of the exception within our application.

I hope this additional information offers something useful.

Screenshot 2021-05-05 at 21.45.13.png

Screenshot 2021-05-05 at 21.46.56.png

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Thu May 06, 2021 1:59 am

Hello,

Thanks for your reply.

According to the error message you provided, I guess that the issue you encountered is likely to be related to the fonts used in your PDF file. Please make sure that you were using the latest Spire.PDF V7.4.13 and all the fonts used in your PDF file have been installed in your environment.

If so, and the issue still exists, then your PDF document is essential for us to investigate and resolve your issue, please provide us with your PDF document and the following information for reference. Thanks in advance.

1. Your testing code
2. Your target framework (E.g. .Net FrameWork 4.6.1)
3. Your system information (E.g. Win7, 64 bit)
4. Your region setting (E.g. China, Chinese)

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu May 06, 2021 8:47 am

The below shows the exception (top middle), and the document properties from Acrobat Reader which show the fonts (bottom right) along with the font settings showing that the font is installed (bottom left).

I will send the document to the support email address. This is as I mentioned in my initial post an intermittent issue. The software is using version 7.3.7 of the .DLL presently - I will try the later version but this has been happening for some time so unless it has been a fix in the last few weeks I'm not sure this will make a difference.

Screenshot 2021-05-06 at 09.33.01.png

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Thu May 06, 2021 10:02 am

Hello,

I have received your email, and thanks for sharing more information!

I did a further testing on the document you provided, and did encounter the prompt message ("parameter is not valid") as you mentioned.

This issue has been submitted to our Dev team with the ticket SPIREPDF-4276 for further investigations. If there is any update, we will keep you informed. Sorry for the inconvenience caused.

However, I still did not reproduce the intermittent issue "Attempted to read or write protected memory" you mentioned in your initial post. To help us further investigate this issue, please provide us with the following information for reference. Thanks in advance.
1. Your testing code
2. Your target framework (E.g. .Net FrameWork 4.6.1)
3. Your system information (E.g. Win7, 64 bit)
4. Your region setting (E.g. China, Chinese)

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon May 17, 2021 4:01 pm

A quick follow-up on this one - Any news from the dev team?

In respect to environmental setup, the machines often have different country and language setups, but mine is set up as US/English Windows 10 Pro patched to the latest patch level. The target OS is generally Windows 10 and the system is 64bit.

I hope this additional information is helpful.

Darren.

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Tue May 18, 2021 3:56 am

Hello,

Thanks for your follow-up and sharing more information!

Our Dev team is still working on your issue, sorry to tell that there is no significant progress so far. Anyway, I urged and requested them to share any possible ETA at their earliest, once there is any good news, we will notify you immediately. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon May 24, 2021 6:33 am

Just a quick check-in on this one. Let me know if there’s any news.

Thanks in advance,

Darren

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Mon May 24, 2021 9:32 am

Dear Darren,

I got the news from the Dev-team that they have found the cause of your issue, but the current solution will have a greater impact on other parts, and we need more time to analyze and investigate it.

Please give us more time to find a better solution. Once the issue SPIREPDF-4276 is resolved, I will notify you immediately.

Thanks for your patience!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jun 07, 2021 5:36 am

Just a quick check-in on this issue. Any news from the development team?

Thanks in advance,

Darren

wraydc
 
Posts: 130
Joined: Wed Apr 11, 2018 5:14 am

Mon Jun 07, 2021 10:58 am

Hello,

Thanks for your follow-up!

I have asked our development team about the progress of the ticket SPIREPDF-4276. They have found a solution, and now they are testing whether it is feasible. Anyway, I have given this issue a higher priority, and requested our development team to share any possible ETA at their earliest.

Once there is any good news, we will notify you immediately. Sorry for the inconvenience caused, and thanks again for your patience.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF