Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#14413 closed bug (fixed)

Crash when "delete BMessage->Previous()"

Reported by: ahwayakchih Owned by: nielx
Priority: normal Milestone: Unscheduled
Component: Documentation Version: R1/Development
Keywords: BMessage, crash Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Documentation of BMessage::Previous says that caller SHOULD delete resulting BMessage. But when i do that, BLooper crashes soon after return from MessageReceived.

Documentation: https://www.haiku-os.org/docs/api/classBMessage.html#a57c84d02e54ef19fd1516d9bf7e3fe45

I'm attaching mini application that shows the problem. I know it's strange to send message to itself, but it's to closely mimick code that discovered the problem.

My Deskbar replicant has to use PostMessage because on Haiku it cannot get Deskbar location otherwise (outside of some ugly hacks): https://github.com/haiku/haiku/blob/4824497d01271c34dc86e092f2df96d6352e452c/src/kits/interface/Deskbar.cpp#L121-L124 So it posts message and waits for reply in MessageReceived, where it gets previous message to make sure it's the right reply message.

Attachments (2)

test-bmsg-previous-delete.cpp (3.7 KB ) - added by ahwayakchih 14 months ago.
test application to run with or without deleting previous BMessage
test-bmsg-previous-delete.2.cpp (3.7 KB ) - added by ahwayakchih 14 months ago.
same test app, fixed to post message after ready to run, as advised by PulkoMandy

Download all attachments as: .zip

Change History (5)

by ahwayakchih, 14 months ago

test application to run with or without deleting previous BMessage

by ahwayakchih, 14 months ago

same test app, fixed to post message after ready to run, as advised by PulkoMandy

comment:1 by ahwayakchih, 14 months ago

PulkoMandy said that message should never be deleted, so i checked BeBook (should ahve done that in the first place... sorry): https://www.haiku-os.org/legacy-docs/bebook/BMessage.html and it looks like it does not mention deleting at all.

So this bug is about invalid description of BMessage::Previous in HaikuBook.

Last edited 14 months ago by ahwayakchih (previous) (diff)

comment:2 by pulkomandy, 14 months ago

Component: Kits/Application KitDocumentation
Owner: changed from nobody to nielx
Resolution: fixed
Status: newclosed

Fixed in hrev52296. Also submitted to Gerrit for inclusion in r1b1 as https://review.haiku-os.org/#/c/haiku/+/488/

comment:3 by ahwayakchih, 14 months ago

Thanks :)

Note: See TracTickets for help on using tickets.