PureBasic 6.40 alpha 4 PurePDF crashes

Post bugreports for the Windows version here
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 290
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

PureBasic 6.40 alpha 4 PurePDF crashes

Post by DeanH »

Testing alpha 4, I found a spot in Normeus' PurePDF that causes a crash. This happened with both C and ASM backends.
The line to return the version is highighted when the crash happens.

Code: Select all

Procedure.l ipdf_EndianL(value.l)
	ProcedureReturn (value>>24&$ff)|(value>>8&$ff00)|(value<<24&$ff000000)|(value<<8&$ff0000)
EndProcedure

Procedure.i ipdf_TTF_SearchTagName(*TTF_Memory.TTF_Header,TagName.s)
	Protected Version,numTables,searchRange,entrySelector,rangeShift
	Protected *OffsetTable.TTF_Header_Table
	Protected tag.s,checkSum.l,offset.l,Tlength.l
	If *TTF_Memory
		Version       = ipdf_EndianL(*TTF_Memory\sfnt_version)		;<<<<<<<<<<<< crashes with this line highlighted
		numTables     = ipdf_EndianW(*TTF_Memory\numTables)
		searchRange   = ipdf_EndianW(*TTF_Memory\searchRange)
		entrySelector = ipdf_EndianW(*TTF_Memory\entrySelector)
		rangeShift    = ipdf_EndianW(*TTF_Memory\rangeShift)
		If Version = $10000 ; 0x00010000 for version 1.0 / can be 'true' or 'typ1' on Apple Systems
			*OffsetTable=*TTF_Memory+SizeOf(TTF_Header)
			While numTables>0
				tag      = PeekS(@*OffsetTable\tag,4,#PB_Ascii)
				checkSum = ipdf_EndianL(*OffsetTable\checkSum)
				offset   = ipdf_EndianL(*OffsetTable\offset)
				Tlength  = ipdf_EndianL(*OffsetTable\length)
				;Debug "tag="+tag
				;Debug "checkSum="+Hex(checkSum,#PB_Long)
				;Debug "offset="+Hex(offset,#PB_Long)
				;Debug "Tlength="+Hex(Tlength,#PB_Long)
				;Calc.l      = ipdf_TTF_CalcTableChecksum(*TTF_Memory+offset,Tlength)
				;Debug "Calc="+Hex(Calc,#PB_Long)
				;If checkSum <> Calc
				;  Debug Hex(checkSum,#PB_Long) + "<>" + Hex(Calc,#PB_Long)
				;EndIf
				If tag = TagName
					ProcedureReturn *TTF_Memory+offset
				EndIf
				*OffsetTable+SizeOf(TTF_Header_Table)
				numTables-1
			Wend
		EndIf
	EndIf
EndProcedure
I am also getting a Debug Quit on OpenDatabase (SQLite) but not consistently. I have been trying to track down the trigger but so far have not been able to do that. No Debug Quit with 6.30 LTS. Still investigating.
normeus
Enthusiast
Enthusiast
Posts: 491
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PureBasic 6.40 alpha 4 PurePDF crashes

Post by normeus »

I have not tried 6.40 yet, but looking at some of the comments for 6.40 I think it has to do with the list that is used to keep the names of the fonts:

Code: Select all

  Global NewList FontList.PDF_ObjectStructure()
When I get a chance, I'll take a look...



Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 290
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: PureBasic 6.40 alpha 4 PurePDF crashes

Post by DeanH »

Thanks, Norm. I appreciate it. I have used this quite a bit in my school library management system. It is used in many places. I rolled my own printer selection dialog and included a Preview "printer" which generates and opens a pdf by running it. Some functions, like Overdue Notices, can generate pdf's a school can then attach to emails.
normeus
Enthusiast
Enthusiast
Posts: 491
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PureBasic 6.40 alpha 4 PurePDF crashes

Post by normeus »

DeanH,
I downloaded 6.40 alpha 4 x64, PurePDF using ASM and C compiler works fine. The only problem I had was when using FontRequester to choose a font, I picked a font that was installed by windows 11, here:

Code: Select all

%USERPROFILE%\AppData\Local\Microsoft\Windows\Fonts
PurePDF expects fonts to be in "C:\Windows\Fonts"

I know you said 6.30 works fine, but I hope that's the problem you are running into. I remember someone had a question about the same thing with "pbPDFModule" and there is a workaround for that problem there. Try to run this simple test and see if it crashes:

Code: Select all

#PurePDF_Include=1
XIncludeFile "PurePDF.pb"

pdf_Create()
pdf_AddPage()

fresult=FontRequester("Arial",14, #PB_FontRequester_Effects)
fname$=SelectedFontName()
fsize=SelectedFontSize()
Debug fname$
pdf_SetFont(fname$,"",fsize)
pdf_text(10,10,pdf_Textstring("This is an embedded font ("+fname$+" Size "+Str(fsize)+")"))

pdf_SetFont("Verdana","B",12)
pdf_Text(10,20,"This is an embedded font (Verdana Size 12 Bold)")

pdf_SetFont("Verdana","I",12)
pdf_Text(10,30,"This is an embedded font (Verdana Size 12 Italic")

pdf_SetFont("Verdana","BIU",12)
pdf_Text(10,40,"This is an embedded font (Verdana Size 12) Bold+ITALIC+Underlined")

Define file$="Test_Font.pdf"

pdf_Save(file$)
RunProgram(file$)

Let me know if this code works for you.

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Post Reply