Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12271 closed bug (fixed)

Printing crashes application in BPrivate::PrintServerMessenger::RejectUserInput()

Reported by: diver Owned by: axeld
Priority: normal Milestone: Unscheduled
Component: Kits Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description (last modified by jackburton)

hrev49491. Trying to print or doing page setup from any app causes a crash: for example, Showimage: File->Print... crash.

0x79771880	0xe947a3	BPrivate::PrintServerMessenger::RejectUserInput() + 0x87 
[...]
0x797718b0	0xe94696	__Q28BPrivate20PrintServerMessengerUlP8BMessage + 0x42 
0x79771900	0xe927df	BPrintJob::ConfigJob() + 0x2b 
0x79771ad0	0x120f7cc	ShowImageWindow::_PrepareForPrint() + 0x48 
0x79771bc0	0x120d81b	ShowImageWindow::MessageReceived(BMessage*) + 0x123f 
0x79771bf0	0xe07a99	BLooper::DispatchMessage(BMessage*, BHandler*) + 0x59 
0x79771dd0	0xee7be0	BWindow::DispatchMessage(BMessage*, BHandler*) + 0x176c 
0x79771e30	0xeebbd2	BWindow::task_looper() + 0x28e 
0x79771e60	0xe08f41	BLooper::_task0_(void*) + 0x3d 
0x79771e88	0x2700c7d	thread_entry + 0x21 
00000000	0x609a0250	commpage_thread_exit + 0

Attachments (1)

ShowImage-2422-debug-02-08-2015-09-16-10.report (24.9 KB) - added by diver 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by jackburton

StyledEdit crashes with the same stack trace

comment:2 Changed 4 years ago by jackburton

Description: modified (diff)
Summary: [ShowImage] crashes in BPrivate::PrintServerMessenger::RejectUserInput()Printing crashes application in BPrivate::PrintServerMessenger::RejectUserInput()

comment:3 Changed 4 years ago by jackburton

Could be a regression caused by the launch daemon ?

comment:4 Changed 4 years ago by diver

Maybe the crash in PrintServerMessenger::RejectUserInput() is related to hrev49481?

comment:5 in reply to:  4 Changed 4 years ago by jackburton

Replying to diver:

Maybe the crash in PrintServerMessenger::RejectUserInput() is related to hrev49481?

Yeah, that seems a better candidate than the introduction of the launch_daemon

comment:6 Changed 4 years ago by jackburton

From a cursory look, one problem seems to be that the window default button is set in BAlert::Go(), while it was set in the constructor before. Since this code dereference DefaultButton() without checking for NULL, this might very well be the cause of the crash.

comment:7 Changed 4 years ago by jackburton

Adding the following code:

if (CountButtons() > 0)
		SetDefaultButton(ButtonAt(CountButtons() - 1));

to the end of BAlert::_Init() fixes the crash. Although now we have a nice BAlert shown on the screen. I admit the code in there is sort of a hack, since it creates a BAlert and moves it out of the screen to hide it and block user input.

comment:8 Changed 4 years ago by diver

Owner: changed from nobody to axeld
Status: newassigned

comment:9 Changed 4 years ago by jackburton

Resolution: fixed
Status: assignedclosed

Diver, thanks for the hint. It's fixed in hrev49596, although :

  1. The code in there doesn't look nice.
  2. The changes in hrev49481 could still cause other problems, since it's an API behaviour change.

comment:10 Changed 4 years ago by jessicah

With the changes to BAlert, wouldn't it be simpler (and less API breakage) to move the call to SetDefaultButton(ButtonAt(CountButtons() - 1)) inside BAlert::_Prepare() into the new BAlert::AddButton() function? E.g.

void
BAlert::AddButton(const char* label, char key)
{
    ...
    SetDefaultButton(button);
    fButtonLayout->AddView(button);
}

Given that the API documentation states that the last button is, by convention, the default button, and this always creates a new last button, it will automatically set up the default button correctly, as AddButton() is called from _Init() and the existing non-default constructors.

This would remove the hack introduced in hrev49596 for the default button, and avoid possible crashes in other uses of the originally documented BAlert API.

Note: See TracTickets for help on using tickets.