<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:59:33 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CXX-554] mongo::Date_t::toTimeT() crash</title>
                <link>https://jira.mongodb.org/browse/CXX-554</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;Read a date which is defined as ISODate(&quot;0001-01-01T00:00:00Z&quot;)  from mongodb into a Date_t, then calling toTimeT() crashes, probably because time_t cannot represent dates before 1970 and the conversion doesn&apos;t check this.&lt;br/&gt;
No exception thrown neither - try/catch block could not handle the case.&lt;/p&gt;

&lt;p&gt;(gdb) bt&lt;br/&gt;
#0  0x00007f92545b35db in raise () from /lib64/libpthread.so.0&lt;br/&gt;
#1  0x00000000006b2c47 in mongo::mongo_breakpoint() ()&lt;br/&gt;
#2  0x00000000006aca17 in mongo::verifyFailed(char const*, char const*, unsigned int) ()&lt;br/&gt;
#3  0x00000000006bedf4 in mongo::Date_t::toTimeT() const ()&lt;/p&gt;</description>
                <environment></environment>
        <key id="188819">CXX-554</key>
            <summary>mongo::Date_t::toTimeT() crash</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="adam.midvidy">Adam Midvidy</assignee>
                                    <reporter username="christian.wyss@gfk.com">Christian Wyss</reporter>
                        <labels>
                            <label>legacy-cxx</label>
                    </labels>
                <created>Wed, 11 Mar 2015 11:25:22 +0000</created>
                <updated>Thu, 2 Apr 2015 08:01:30 +0000</updated>
                            <resolved>Wed, 11 Mar 2015 16:00:41 +0000</resolved>
                                    <version>legacy-0.0-26compat-2.6.6</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="871191" author="christian.wyss@gfk.com" created="Thu, 2 Apr 2015 08:01:30 +0000"  >&lt;p&gt;Hello Adam&lt;/p&gt;

&lt;p&gt;I think you must be misunderstanding.&lt;br/&gt;
We have ISODate(&quot;0001-01-01T00:00:00Z&quot;) stored in the MongoDB. This works fine.&lt;br/&gt;
We then read this field - by a query or whatever - into a Date_t structure via C++ code. Works fine, too.&lt;/p&gt;

&lt;p&gt;BUT: when I now call toTimeT() on that structure: segfault.&lt;/p&gt;

&lt;p&gt;It&apos;s clear to me WHY this happens: this date cannot be represented as a time_t, which - in most of today&apos;s systems - has been replaced by an unsigned 64 bit integer - but still starts 1970, so year 0000 is out of the allowed range.&lt;/p&gt;

&lt;p&gt;But this should at least be checked and signalled by an exception - instead it segfaults, what I consider a bug.&lt;/p&gt;
</comment>
                            <comment id="848920" author="adam.midvidy" created="Wed, 11 Mar 2015 15:58:28 +0000"  >&lt;p&gt;Hey Christian,&lt;/p&gt;

&lt;p&gt;Date_t  is represented internally as a 64-bit unsigned integer - so when a Date_t is created from a negative pre-1970 value, it is converted to a (large) positive value. There is currently an assert in the toTimeT() call to check that the value of the Date_t can fit in a time_t, which is a 32 bit signed integer on many systems. This is an unfriendly interface, but we have decided to be very conservative about making changes to the 26compat branch. &lt;/p&gt;

&lt;p&gt;As a workaround, check the result of the isFormattable() method on Date_t before calling toTimeT().&lt;/p&gt;

&lt;p&gt;There is a ticket, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-8573&quot; title=&quot;Make Date_t::millis signed&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-8573&quot;&gt;&lt;del&gt;SERVER-8573&lt;/del&gt;&lt;/a&gt;, to fix this issue in the server sources. When it is resolved, the fix may be backported to the legacy branch, but likely not 26compat.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Adam&lt;/p&gt;
</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs707z:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="313">Platform 0 3/13/15</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>