[SERVER-14843] Can't sniff with mongosniff without causing a coredump Created: 09/Aug/14  Updated: 11/Jul/16  Resolved: 03/Sep/14

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 2.4.11, 2.6.4, 2.7.5
Fix Version/s: 2.7.6

Type: Bug Priority: Major - P3
Reporter: Juan Berner Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: cap-ticket-needed, community-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongosniff tool


Issue Links:
Tested
Operating System: ALL
Steps To Reproduce:

Just install mongo sniff the following way:

git clone https://github.com/mongodb/mongo.git
cd mongo
scons mongosniff

And execute ./mongosniff in a mongo 2.6.3 server

I have tested it in ubuntu 12.04 and Red Hat Enterprise Linux Server release 6.3 (Santiago)

Participants:

 Description   

I'm trying to sniff mongo traffic from a server with version 2.6.3 with a 2.6.3 mongosniff version and have the following result when a command is sent to the mongo server.

[root@e-x mongo]# ./mongosniff 6612
found device: eth0
sniffing... 6612
Multiple messages in packet, skipping packet.
Multiple messages in packet, skipping packet.
Multiple messages in packet, skipping packet.
10.32.164.94:49382  -->> 10.32.164.94:6612 admin.$cmd  58 bytes  id:34ace5      3452133
        query: { ismaster: 1 }  ntoreturn: 1 ntoskip: 0
2014-08-08T19:54:02.800-0400 I          Assertion failure messageShouldHaveNs() src/mongo/db/dbmessage.cpp 94
2014-08-08T19:54:02.810-0400 I          
 0xf259fe 0xed9ad1 0xec4be9 0x9c1fa0 0x7c7088 0x7f846e042ab2 0x7f846e0478c1 0x7c6415 0x7c6a19 0x3104a1ecdd 0x7c4149
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"B259FE"},{"b":"400000","o":"AD9AD1"},{"b":"400000","o":"AC4BE9"},{"b":"400000","o":"5C1FA0"},{"b":"400000","o":"3C7088"},{"b":"7F846E03B000","o":"7AB2"},{"b":"7F846E03B000","o":"C8C1"},{"b":"400000","o":"3C6415"},{"b":"400000","o":"3C6A19"},{"b":"3104A00000","o":"1ECDD"},{"b":"400000","o":"3C4149"}],"processInfo":{ "mongodbVersion" : "2.7.5-pre-", "gitVersion" : "1232c89874a8763375b65c438680e8441f65f021", "uname" : { "sysname" : "Linux", "release" : "2.6.32-279.1.1.el6.x86_64", "version" : "#1 SMP Wed Jun 20 11:41:22 EDT 2012", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000", "buildId" : "A9CBCE20493E9C114AD47F0A3FA06B5DBAF93DAA" }, { "b" : "7FFF7BB8E000", "elfType" : 3, "buildId" : "84935069344ED53D05E2911F88525B53C45B809E" }, { "path" : "/lib64/libpthread.so.0", "elfType" : 3, "buildId" : "14853815DD64F2B830B8DCCB3A958A3804E13EFC" }, { "path" : "/lib64/librt.so.1", "elfType" : 3, "buildId" : "5E9DDD9EE40AD0D4DDD032CE1086E402B7FA955A" }, { "path" : "/lib64/libdl.so.2", "elfType" : 3, "buildId" : "15B0822C819020F18BBF0E0C0286373155E03BE2" }, { "b" : "7F846E03B000", "path" : "/usr/lib64/libpcap.so.1", "elfType" : 3, "buildId" : "296263462B440F6D16C3B84A73C409D751D0C7C8" }, { "path" : "/usr/lib64/libstdc++.so.6", "elfType" : 3, "buildId" : "1A4BC78E7DA0FA025262D516D00E04AFD1B0F429" }, { "path" : "/lib64/libm.so.6", "elfType" : 3, "buildId" : "A26BC945B5765B1258DB01FFEFB0C4F53F3961D7" }, { "path" : "/lib64/libgcc_s.so.1", "elfType" : 3, "buildId" : "CE152B8676517F23E7F54AD6408330979BE41443" }, { "path" : "/lib64/libc.so.6", "elfType" : 3, "buildId" : "90D43C0C93FF34D4CE67692E149343DD372EEC78" }, { "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "D6BD776B36DAC438642CF84B282956738727901D" } ] }}
 mongosniff(_ZN5mongo15printStackTraceERSo+0x2E) [0xf259fe]
 mongosniff(_ZN5mongo10logContextEPKc+0xD1) [0xed9ad1]
 mongosniff(_ZN5mongo12verifyFailedEPKcS1_j+0x1A9) [0xec4be9]
 mongosniff(_ZNK5mongo9DbMessage17getQueryNToReturnEv+0x0) [0x9c1fa0]
 mongosniff(_Z10got_packetPhPK11pcap_pkthdrPKh+0x668) [0x7c7088]
 libpcap.so.1(+0x7AB2) [0x7f846e042ab2]
 libpcap.so.1(pcap_loop+0x51) [0x7f846e0478c1]
 mongosniff(_Z8toolMainiPPcS0_+0x8E5) [0x7c6415]
 mongosniff(main+0x9) [0x7c6a19]
 libc.so.6(__libc_start_main+0xFD) [0x3104a1ecdd]
 mongosniff(+0x3C4149) [0x7c4149]
-----  END BACKTRACE  -----
terminate called after throwing an instance of 'mongo::AssertionException'
  what():  assertion src/mongo/db/dbmessage.cpp:94
Aborted (core dumped)

Thanks!



 Comments   
Comment by Githook User [ 03/Sep/14 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-14843: Fix mongosniff for decoding messages without a namespace
Branch: master
https://github.com/mongodb/mongo/commit/5d05a2b0767f2f6122ee509678e0df3fa36f94a7

Comment by Matt Kangas [ 29/Aug/14 ]

This is a side effect of SERVER-14268. It fails the verify(messageShouldNaveNs()) within DbMessage::getns() added in commit dac9ac4.

The "Steps to reproduce" above indicate that the submitter actually built mongosniff from master, not 2.6.3.

Comment by Juan Berner [ 09/Aug/14 ]

I solved the issue changing the code in src/mongo/db/dbmessage.h, added a return true to function messageShouldHaveNs

bool messageShouldHaveNs() const

{ return true; return (_msg.operation() >= dbMsg) & (_msg.operation() <= dbDelete); }

And after compiling it its working fine.

Thanks!

Comment by Juan Berner [ 09/Aug/14 ]

The mongo version is:

[root@e-00006b32 mongo]# mongod --version
db version v2.6.3
2014-08-08T20:21:42.121-0400 git version: 255f67a66f9603c59380b2a389e386910bbb52cb

Generated at Thu Feb 08 03:36:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.