Opened 3 years ago

Closed 3 years ago

#16823 closed bug (fixed)

net_server: crash when receiving B_ABOUT_REQUESTED

Reported by: X512 Owned by: jscipione
Priority: normal Milestone: R1/beta4
Component: Servers/net_server Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

This is hrev54837.

Steps to reproduce:

  1. Run in Terminal: hey application/x-vnd.haiku-net_server '_ABR'.
  2. net_server will crash.

net_server implements B_ABOUT_REQUESTED handling here: https://git.haiku-os.org/haiku/tree/src/servers/net/NetServer.cpp#n158.

While testing I found that only debug_server correctly responts to B_ABOUT_REQUESTED message. Other servers and most applications do nothing.

Attachments (1)

net_server-9328-debug-02-03-2021-03-17-09.report (15.8 KB ) - added by X512 3 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by X512, 3 years ago

Note that it crash in BTextView initialization.

comment:2 by jscipione, 3 years ago

Owner: changed from axeld to jscipione
Status: newassigned

I guess this must be something I've overlooked in BTextView _UpdateInsets() (NULL pointer exception or similar).

comment:3 by jscipione, 3 years ago

be_control_look is NULL in BAlert::_Init(). How is that possible? How to fix?

comment:4 by pulkomandy, 3 years ago

Probably because net_server is started early (before app_server) and initializing the control look needs collaboration from app_server?

I suggest just removing the about box from net_server. We don't need to have about boxes in each and every executable.

comment:5 by jscipione, 3 years ago

Unfortunately no, net_server starting before app_server is not it because I restarted my net_server. I believe that the problem is that BAlert inherits from BWindow and so there's no connection to app_server during BWindow constructor. To fix this we have to run _Init() after the object is constructed in another method or by making the connection to app server early.

I'm pretty sure net_server doesn't really have an about box anyway, but unfortunately that doesn't stop somebody from using hey to send net_server an AboutRequested ('_ABR') message.

I don't know what BWindow method to use that will run right after the object is constructed. There's no AttachedToWindow() or AllAttached() for a BWindow, only a BView. Could I put _Init() in Run() perhaps? Could I attach a BView to BAlert and then attach everything else as a child to that view in AttachedToWindow()?

In any case, there's no bug in BTextView so I didn't cause this crash, it just happened to be the first time be_control_look was used. It's one of the few pointers used in BTextView::_UpdateInsets() so it was pretty easy to track down that a NULL be_control_look was the cause. Skipping over _UpdateInsets() just makes net_server crash a bit later when it tries to use be_control_look in a different place.

comment:6 by pulkomandy, 3 years ago

I'm pretty sure net_server doesn't really have an about box anyway, but unfortunately that doesn't stop somebody from using hey to send net_server an AboutRequested ('_ABR') message.

The code in net_server that runs the BAlert is linked in the ticket description. We just need to empty that method and nothing will happen when the message is received.

I believe that the problem is that BAlert inherits from BWindow and so there's no connection to app_server during BWindow constructor. To fix this we have to run _Init() after the object is constructed in another method or by making the connection to app server early.

No, the fix is to make sure the window is created after the app_server connection is established (by creating a BApplication), or, if there is no BApplication, not try to open a window, because that's not allowed without a BApplication, and various strange things will happen if you try to do it anyway.

comment:7 by jscipione, 3 years ago

OK I see now, let's remove the offending code if not needed. No BApplication, no about dialog, got it.

comment:8 by pulkomandy, 3 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: assignedclosed

Fixed in hrev55293.

Note: See TracTickets for help on using tickets.