[SERVER-13760] mongoexport crashes on large timestamps on Windows Created: 28/Apr/14  Updated: 11/Jul/16  Resolved: 27/May/14

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.6.0
Fix Version/s: 2.6.2, 2.7.2

Type: Bug Priority: Major - P3
Reporter: Andrew Ryder (Inactive) Assignee: Shaun Verch
Resolution: Done Votes: 2
Labels: tools, windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
Operating System: Windows
Backport Completed:
Steps To Reproduce:

1. Clean start at a shell:

> use test
> db.test.insert( { ts: ISODate("3001-01-01T08:00:00.000Z") } );


2. Command-prompt:

mongoexport -d test -c test

Sprint: Server 2.7.1, Server 2.7.2
Participants:
Linked BF Score: 0

 Description   
Issue Status as of May 28, 2014

ISSUE SUMMARY
On Windows 7 and 8, mongoexport crashes when documents to be exported contain a timestamp greater than 3001-01-01T07:59:59.999Z.

USER IMPACT
Documents containing these high timestamps can't be exported using mongoexport.

WORKAROUNDS
Use mongodump to dump collections with documents containing these large timestamps.

AFFECTED VERSIONS
MongoDB production releases 2.6.0 and 2.6.1 are affected by this issue.

FIX VERSION
The fix is included in the 2.6.2 production release.

RESOLUTION DETAILS
Do not attempt to convert these high timestamps to an ISO String, but export them as {"$numberLong": "<milliseconds>"} instead.

Original description

If a document contains a timestamp greater than 3001-01-01T07:59:59.999Z then mongoexport will crash attempting to export it when run on Windows. Known to occur on Windows 7 & 8.

The crash dump produced by running a debug build (and following the steps to reproduce) is as follows:

>mongoexport.exe -d test -c test
connected to: 127.0.0.1
2014-04-28T17:01:01.367+1000 *** C runtime error: f:\dd\vctools\crt_bld\self_64_amd64\crt\src\wcsftime.c(589) : Assertion failed: ( ( timeptr->tm_mon >=0 ) && ( timeptr->tm_mon <= 11 ) ), terminating
2014-04-28T17:01:01.394+1000 Fatal Assertion 17006
2014-04-28T17:01:01.851+1000 mongoexport.exe  ...\src\mongo\util\stacktrace.cpp(172)                       mongo::printStackTrace+0x5b
2014-04-28T17:01:01.860+1000 mongoexport.exe  ...\src\mongo\util\log.cpp(127)                              mongo::logContext+0xd8
2014-04-28T17:01:01.873+1000 mongoexport.exe  ...\src\mongo\util\assert_util.cpp(139)                      mongo::fassertFailed+0x94
2014-04-28T17:01:01.885+1000 mongoexport.exe  ...\src\mongo\util\stacktrace.cpp(288)                       mongo::crtDebugCallback+0x107
2014-04-28T17:01:01.898+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrptt.c(609)   _VCrtDbgReportW+0x7c1
2014-04-28T17:01:01.914+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrpt.c(263)    _CrtDbgReportWV+0x50
2014-04-28T17:01:01.930+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrpt.c(279)    _CrtDbgReportW+0x60
2014-04-28T17:01:01.947+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\wcsftime.c(589)  _W_expandtime+0xaa9
2014-04-28T17:01:01.968+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\wcsftime.c(323)  _Wcsftime_l+0x48b
2014-04-28T17:01:01.992+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\strftime.c(285)  _Strftime_l+0x4be
2014-04-28T17:01:02.013+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\strftime.c(190)  strftime+0x43
2014-04-28T17:01:02.033+1000 mongoexport.exe  ...\src\mongo\util\time_support.cpp(125)                     mongo::`anonymous namespace'::_dateToISOString+0x82
2014-04-28T17:01:02.059+1000 mongoexport.exe  ...\src\mongo\util\time_support.cpp(191)                     mongo::dateToISOStringLocal+0x5a
2014-04-28T17:01:02.085+1000 mongoexport.exe  ...\src\mongo\db\jsobj.cpp(218)                              mongo::BSONElement::jsonString+0x12ed
2014-04-28T17:01:02.105+1000 mongoexport.exe  ...\src\mongo\db\jsobj.cpp(479)                              mongo::BSONObj::jsonString+0x16e
2014-04-28T17:01:02.126+1000 mongoexport.exe  ...\src\mongo\tools\export.cpp(224)                          Export::run+0xbb7
2014-04-28T17:01:02.148+1000 mongoexport.exe  ...\src\mongo\tools\tool.cpp(143)                            mongo::Tool::main+0x4a7
2014-04-28T17:01:02.170+1000 mongoexport.exe  ...\src\mongo\tools\tool.cpp(387)                            wmain+0xec
2014-04-28T17:01:02.188+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c(241)      __tmainCRTStartup+0xec
2014-04-28T17:01:02.211+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c(164)      wmainCRTStartup+0xe
2014-04-28T17:01:02.232+1000
2014-04-28T17:01:02.239+1000 *** unhandled exception 0x80000003 at 0x000007FC4712478A, terminating
2014-04-28T17:01:02.259+1000 *** stack trace for unhandled exception:
2014-04-28T17:01:02.709+1000 KERNELBASE.dll                                                                DebugBreak+0x2
2014-04-28T17:01:02.722+1000 mongoexport.exe  ...\src\mongo\util\debug_util.cpp(48)                        mongo::mongo_breakpoint+0x22
2014-04-28T17:01:02.738+1000 mongoexport.exe  ...\src\mongo\util\debug_util.h(65)                          mongo::breakpoint+0x25
2014-04-28T17:01:02.756+1000 mongoexport.exe  ...\src\mongo\util\assert_util.cpp(140)                      mongo::fassertFailed+0x99
2014-04-28T17:01:02.775+1000 mongoexport.exe  ...\src\mongo\util\stacktrace.cpp(288)                       mongo::crtDebugCallback+0x107
2014-04-28T17:01:02.797+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrptt.c(609)   _VCrtDbgReportW+0x7c1
2014-04-28T17:01:02.815+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrpt.c(263)    _CrtDbgReportWV+0x50
2014-04-28T17:01:02.835+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgrpt.c(279)    _CrtDbgReportW+0x60
2014-04-28T17:01:02.857+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\wcsftime.c(589)  _W_expandtime+0xaa9
2014-04-28T17:01:02.879+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\wcsftime.c(323)  _Wcsftime_l+0x48b
2014-04-28T17:01:02.901+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\strftime.c(285)  _Strftime_l+0x4be
2014-04-28T17:01:02.921+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\strftime.c(190)  strftime+0x43
2014-04-28T17:01:02.941+1000 mongoexport.exe  ...\src\mongo\util\time_support.cpp(125)                     mongo::`anonymous namespace'::_dateToISOString+0x82
2014-04-28T17:01:02.958+1000 mongoexport.exe  ...\src\mongo\util\time_support.cpp(191)                     mongo::dateToISOStringLocal+0x5a
2014-04-28T17:01:02.971+1000 mongoexport.exe  ...\src\mongo\db\jsobj.cpp(218)                              mongo::BSONElement::jsonString+0x12ed
2014-04-28T17:01:02.986+1000 mongoexport.exe  ...\src\mongo\db\jsobj.cpp(479)                              mongo::BSONObj::jsonString+0x16e
2014-04-28T17:01:03.002+1000 mongoexport.exe  ...\src\mongo\tools\export.cpp(224)                          Export::run+0xbb7
2014-04-28T17:01:03.016+1000 mongoexport.exe  ...\src\mongo\tools\tool.cpp(143)                            mongo::Tool::main+0x4a7
2014-04-28T17:01:03.029+1000 mongoexport.exe  ...\src\mongo\tools\tool.cpp(387)                            wmain+0xec
2014-04-28T17:01:03.044+1000 mongoexport.exe  f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c(241)      __tmainCRTStartup+0xec
2014-04-28T17:01:03.068+1000
2014-04-28T17:01:03.074+1000 writing minidump diagnostic file C:\Users\Xarium\Documents\GitHub\mongo\mongoexport.2014-04-28T07-01-03.mdmp
2014-04-28T17:01:03.194+1000 *** immediate exit due to unhandled exception



 Comments   
Comment by Githook User [ 31/Jul/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-13760 added check on source collection size before running mongoexport

(cherry picked from commit 0f45edb3e83bef553ae70c4cbab4c08319f2fd61)
Branch: v2.6
https://github.com/mongodb/mongo/commit/675063a05e18d6d0ab7d280c794d3b61e5e71b70

Comment by Githook User [ 31/Jul/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-13760 added check on source collection size before running mongoexport
Branch: master
https://github.com/mongodb/mongo/commit/0f45edb3e83bef553ae70c4cbab4c08319f2fd61

Comment by Shaun Verch [ 30/May/14 ]

Backport completed after resolving merge conflict with https://github.com/mongodb/mongo/commit/962b4ab67f58e80c2ee7d82f9415017d8fc17056

Comment by Githook User [ 30/May/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13760 Do not call dateToISOString if date is not formatable
(cherry picked from commit 99fa4e6058a24d6c4d7fde19ce940719c5bbc210)
Branch: v2.6
https://github.com/mongodb/mongo/commit/ad9df9f23b3ff4c831ff642817bd2befb8bf4609

Comment by Githook User [ 23/May/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13760 Do not call dateToISOString if date is not formatable
Branch: master
https://github.com/mongodb/mongo/commit/99fa4e6058a24d6c4d7fde19ce940719c5bbc210

Comment by Githook User [ 21/May/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: Revert "SERVER-13760 Do not call dateToISOString if date is not formatable"

This reverts commit 3b97c0870427f676cf3ffbddabc5df8b1fa44fa5.
Branch: master
https://github.com/mongodb/mongo/commit/b162d4c90ed069602ea2dbdac74771d2d97c14ee

Comment by Githook User [ 21/May/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13760 Do not call dateToISOString if date is not formatable
Branch: master
https://github.com/mongodb/mongo/commit/3b97c0870427f676cf3ffbddabc5df8b1fa44fa5

Comment by Githook User [ 16/May/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: Revert "SERVER-13760 Do not call dateToISOString if date is not formatable"

This reverts commit bf5f075b3b73c242042be8fd2c0b9b60af5f0089, which broke the build.
Branch: master
https://github.com/mongodb/mongo/commit/47de28a936dd9d8081089d3e761c2ce74c1ad19f

Comment by Githook User [ 16/May/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13760 Do not call dateToISOString if date is not formatable
Branch: master
https://github.com/mongodb/mongo/commit/bf5f075b3b73c242042be8fd2c0b9b60af5f0089

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