[SERVER-42032] mongodb-javascript-stack always fails when running in hang_analyzer.py Created: 01/Jul/19  Updated: 29/Oct/23  Resolved: 12/Jul/19

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 4.2.0-rc3, 4.3.1

Type: Bug Priority: Major - P3
Reporter: Pavithra Vetriselvan Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: tig-hanganalyzer
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.2
Sprint: STM 2019-07-29
Participants:
Story Points: 1

 Description   

[2019/06/05 03:28:31.295] Running Print JavaScript Stack Supplement
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack
[2019/06/05 03:28:31.295] Ignoring GDB error 'No type "mozjs" within class or namespace "mongo".' in javascript_stack

https://evergreen.mongodb.com/task_log_raw/mongodb_mongo_master_ubuntu1604_replica_sets_auth_1_ubuntu1604_c939010fe98ba0a8affe7d0d30d4e8d57e68242b_19_06_05_00_44_58/0?type=T#L2539


Original description

In gdb, if we're in a frame that does not know about mongo::mozjs:kCurrentScope, then we will not print a javascript stack trace.

This can be especially useful when debugging our integration tests and gdb optimizes variables out of the core dump.

max.hirschhorn figured out that switching the frame in gdb (frame 1) and then running mongodb-javascript-stack will work fine.

Perhaps we can arbitrarily switch frames here before trying to print the stack trace.



 Comments   
Comment by Githook User [ 12/Jul/19 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-42032 Replace parse_and_eval() usage in mongodb-javascript-stack.

(cherry picked from commit 4bdf1fd63dc793a6d36d1f9da660c9747478206b)
Branch: v4.2
https://github.com/mongodb/mongo/commit/9c2a42465d1a711da542c99632ce9c92fa0a80d1

Comment by Githook User [ 12/Jul/19 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-42032 Replace parse_and_eval() usage in mongodb-javascript-stack.
Branch: master
https://github.com/mongodb/mongo/commit/4bdf1fd63dc793a6d36d1f9da660c9747478206b

Comment by Max Hirschhorn [ 01/Jul/19 ]

Interestingly enough, it looks like the SpiderMonkey developers have hit this same kind of issue before in https://bugzilla.mozilla.org/show_bug.cgi?id=1483323. They ended up replacing their usage of gdb.parse_and_eval(). We could do the same by changing the logic in MongoDBJavaScriptStack.javascript_stack() to something along the lines of the following:

current_scope = gdb.lookup_symbol('mongo::mozjs::kCurrentScope')[0].value()
if current_scope and current_scope['_inOp']:
    gdb.execute('thread', from_tty=False, to_string=False)
    gdb.execute(
        'printf "%s\\n", ' +
        'mongo::mozjs::kCurrentScope->buildStackString().c_str()', from_tty=False,
        to_string=False)

Another hack would be to switch frames before running gdb.parse_and_eval(). While this issue was reported for the mongodb-javascript-stack command, there are other usages of gdb.parse_and_eval() which read from thread-local variables. CC acm

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