Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-03

SVN - SIGSEGV in external C lib when Lazarus in Debug mode (Qt)

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I have music player based on Bass library. It can play online radio and signal (metadata) if song in radio has changed. Code is quite old and Bass binary is not changed. Recently I updated SVN source (I need to use it because it has important bug fixes), rebuild Lazarus and receive metadata stopped worked but only in Debug mode, Release is working fine.

This is output in debug mode:

TApplication.HandleException Unknown Run-Time error : 202 Stack trace:
$0000000000437E5F
$00007F38A2AF6634
QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x2812a90), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x2812a90), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPainter::begin: Paint device returned engine == 0, type: 2 QPixmap: It is not safe to use pixmaps outside the GUI thread

Once I saw error refere to TLoggerLazBase(or something like that). And this is the code:

procedure SyncMetaProc(handle: HSYNC; channel, data: DWORD; user: Pointer);
{$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
begin
  // Synchronize with main thread
  Application.QueueAsyncCall(@MusicPlayer.AsyncMetaChanged, 0);
end;
procedure TPlayer.AsyncMetaChanged(Data: PtrInt);
var
  m: PAnsiChar;
  sDef: String;
begin
  m := BASS_ChannelGetTags(FMusic, BASS_TAG_META);
  if (mnil) and Assigned(FOnMeta) then
    FOnMeta(Self, )
  if (MusicPlayer.FPlaylistnil) and
(MusicPlayer.FPlaylist.Indicatornil) then
    sDef := MusicPlayer.FPlaylist.Indicator^.Title
  else
    sDef := 'Unknown';
  FTitle := MusicPlayer.ExtractStreamTitle(BASS_ChannelGetTags(FMusic,
BASS_TAG_META), sdef);
  DoStatus;
end;
begin
    if FSyncMeta=0 then
      FSyncMeta := BASS_ChannelSetSync(FMusic, BASS_SYNC_META, 0,
@SyncMetaProc, nil);
end;

Note that even if I comment Application.QueueAsyncCall.... then I get same error and output. Should I report this with Qt widgetset category?

Tested on Kubuntu 14.04 64bit, FPC 2.6.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160322/fc877417/attachment-0001.html>

Reply by email

Zeljko
to Krzysztof
Krzysztof wrote 39 lines
Hi, I have music player based on Bass library. It can play online radio and signal (metadata) if song in radio has changed. Code is quite old and Bass binary is not changed. Recently I updated SVN source (I need to use it because it has important bug fixes), rebuild Lazarus and receive metadata stopped worked but only in Debug mode, Release is working fine. This is output in debug mode: TApplication.HandleException Unknown Run-Time error : 202 Stack trace: $0000000000437E5F $00007F38A2AF6634 QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x2812a90), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x2812a90), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QObject: Cannot create children for a parent that is in a different thread. (Parent is Oxygen::WidgetStateEngine(0x28161e0), parent's thread is QThread(0x272ddb0), current thread is QThread(0x7f3870000d20) QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPainter::begin: Paint device returned engine == 0, type: 2 QPixmap: It is not safe to use pixmaps outside the GUI thread

1. Try to run your application with another style. eg myapplication -styke plastique and see if you have same problem with children creation.

2.Using QPixmap outside of main thread is a big no-no, for that purpose you must use QImage.

zeljko

Reply by email

Krzysztof
to Zeljko

Tried with style plastique - same result. QPixmap log output is not from my code but from Qt Widgetset, I'm not using Qt API directly, I'm just assigning TLabel.Caption := Title in thread
safe Application.QueueAsyncCall. Tried also prepare demo but when copy pasted to the empty project, everything is working fine. Different stack or something?
I still don't understand why I get this error even when I comment Application.QueueAsyncCall
line in bass callback SyncMetaProc. It is on top place where external Bass callback function call my FPC routine. It worked fine for several months, stopped after svn update and Lazarus rebuild. Weird -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160323/de25c120/attachment.html>

Reply by email

Krzysztof
to Krzysztof

Found what was a problem. I did not associate the fact that few weeks ago I added -dDEBUG to my "Default" and "Debug" build modes. Now I read ( http://wiki.freepascal.org/IDE_Macros_in_paths_and_filenames ) that -dDEBUG is FPC reserved symbol and I didn't know that :( . I didn't add it into "Release" mode and that is why it is working fine here. Weird that everything else is working fine with -dDEBUG except that one external C lib callback. I changed it to -dMYDEBUG and problem solved. Sorry for hesitate -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160324/7976042b/attachment.html>

Reply by email