Page 1 of 1

SetMailBody() in thread and an upgrade from Debian 7 to 8

Posted: Tue Jul 21, 2015 3:43 pm
by infratec
Hi,

strange things:
My SCGI programm written in PB on a Debian 7 64bit PC fails on a PC where I upgraded to Debian 8.

A small test program shows the following:
If I call the procedure without creating a thread it runs on both PCs.
If I call the procedure as thread it generates an IMA on the Debian 8 PC.
On the Debian 7 PC it's still working.

And yes, threadsave is enabled :mrgreen:

Code: Select all

EnableExplicit

Procedure Send(*Dummy)
  
  Protected.i Mail
  Protected Alarm$
  
  Mail = CreateMail(#PB_Any, "supervisor@smarthome.ednt.de", "Test")
  If Mail
    PrintN("created")
    Alarm$ = "That's the main body"
    PrintN("before SetMailBody")
    SetMailBody(Mail, Alarm$)
    PrintN("after SetMailBody")
    AddMailRecipient(Mail, "root@localhost", #PB_Mail_To)
    PrintN("after AddMailRecipient")
    If SendMail(Mail, "127.0.0.1")
      PrintN("success")
    EndIf
  EndIf
  
EndProcedure



Define.i Thread

InitNetwork()

OpenConsole()

PrintN("Called normal:")

Send(0)

PrintN("")
PrintN("Now as thread:")

Thread = CreateThread(@Send(), 0)
WaitThread(Thread)
; IDE Options = PureBasic 5.31 (Linux - x64)
; ExecutableFormat = Console
; CursorPosition = 35
; Folding = -
; EnableThread
; EnableXP
; Executable = SetMailBodyTest
Output on Debian 7
Called normal:
created
before SetMailBody
after SetMailBody
after AddMailRecipient
success

Now as thread:
created
before SetMailBody
after SetMailBody
after AddMailRecipient
success
Output on Debian 8
Called normal:
created
before SetMailBody
after SetMailBody
after AddMailRecipient
success

Now as thread:
created
before SetMailBody
Speicherzugriffsfehler
Any idea what to do :?:

Bernd

Re: SetMailBody() in thread and an upgrade from Debian 7 to

Posted: Wed Jul 22, 2015 10:01 am
by infratec
Additional info:

I installed now PB 5.31 x64 on Debian 8,
compiled it and tried to run it:

Same IMA :!:

Bernd