[SERVER-29012] Undefined behaviour in the ServerStatusSection constructor Created: 28/Apr/17  Updated: 30/Oct/23  Resolved: 01/May/17

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 3.5.6
Fix Version/s: 3.5.7

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Andrew Morrow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-11589 Initialization order fiasco between d... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platforms 2017-05-08
Participants:
Linked BF Score: 0

 Description   

The constructor for ServerStatusSection calls a non-static method on the CmdServerStatus class. Depending on the order of construction of the different sections, this invocation may happen before CmdServerStatus has been constructed.

This was discovered through UBSAN:

src/mongo/db/commands/server_status.cpp:196:21: runtime error: member call on address 0x55555cfde1d8 which does not point to an object of type 'mongo::CmdServerStatus'
0x55555cfde1d8: note: object has invalid vptr
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr

Since CmdServerStatus::_sections is static it doesn't need to be accessed through a non-static function.



 Comments   
Comment by Githook User [ 01/May/17 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: SERVER-29012 Enable ASAN strict init order checking and fix revealed issues
Branch: master
https://github.com/mongodb/mongo/commit/b779cb0bf72267b8d6cefbb4739c118a720026da

Generated at Thu Feb 08 04:19:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.