[SERVER-13446] Solaris builds depend on ILLUMOS libc Created: 31/Mar/14  Updated: 11/Jul/16  Resolved: 22/May/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.6.2, 2.7.1

Type: Bug Priority: Major - P3
Reporter: Ernie Hershey Assignee: Shaun Verch
Resolution: Done Votes: 2
Labels: community-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File test_timegm.log     Text File timegm.patch    
Issue Links:
Related
related to SERVER-14019 Add configure step to check whether t... Closed
related to SERVER-13874 Improve handling of dates, times, and... Closed
Operating System: ALL
Backport Completed:
Sprint: Server 2.7.1
Participants:

 Description   

In Oracle Solaris, this leads to this error:

bash-3.2# ./mongodb-sunos5-x86_64-2.6.0-rc2/bin/mongod
ld.so.1: mongod: fatal: libc.so.1: version 'ILLUMOS_0.1' not found (required by file mongodb-sunos5-x86_64-2.6.0-rc2/bin/mongod)
ld.so.1: mongod: fatal: libc.so.1: open failed: No such file or directory
Killed
bash-3.2#



 Comments   
Comment by Githook User [ 27/May/14 ]

Author:

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

Message: SERVER-13446 Add timegm Solaris implementation to third_party

(cherry picked from commit 1ec7a22e8b10833d250892e62d7e0942b1dbb9f2)

Conflicts:
src/third_party/SConscript
Branch: v2.6
https://github.com/mongodb/mongo/commit/6646cd2d72aecb3b267467598835d0d0ac97614a

Comment by Githook User [ 22/May/14 ]

Author:

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

Message: SERVER-13446 Add timegm Solaris implementation to third_party
Branch: master
https://github.com/mongodb/mongo/commit/1ec7a22e8b10833d250892e62d7e0942b1dbb9f2

Comment by Githook User [ 17/May/14 ]

Author:

{u'username': u'kangas', u'name': u'Matt Kangas', u'email': u'matt.kangas@mongodb.com'}

Message: Revert "SERVER-13446 Add timegm Solaris implementation to third_party"

This reverts commit 5a44bf386eaba7d18a142206868bdbab15432eea.
Reason: time_support_test.cpp fails on Linux 32/Linux 32 DEBUG.
Branch: master
https://github.com/mongodb/mongo/commit/9df8f46db0152921264a6bd235cfd0fd655bf1bc

Comment by Githook User [ 16/May/14 ]

Author:

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

Message: SERVER-13446 Add timegm Solaris implementation to third_party
Branch: master
https://github.com/mongodb/mongo/commit/5a44bf386eaba7d18a142206868bdbab15432eea

Comment by Itay Neeman [ 22/Apr/14 ]

Great - created CXX-204.

Comment by Eric Milkie [ 22/Apr/14 ]

Yes, please file a CXX issue for this. We have a code review prepared for this that we believe will have correct behavior, using IANA's timezone code.

Comment by Itay Neeman [ 22/Apr/14 ]

We need this fix in the C++ driver as well - will this be backported over, or should I file a support CXX issue for it?

Comment by Pavel Ryzhov [ 10/Apr/14 ]

A simple implementation of timegm from https://github.com/vlmarek/notmuch-solaris/blob/master/compat/timegm.c seems to be working fine because MongoDB 2.6 x64 with it on Solaris 11.1 passed all tests.

I am not sure if it is a correct way to patch it but it seems that it just converts struct tm to ms and that is all. Could anybody validate this approach?

PS: Both files in the attachment.

Comment by Pavel Ryzhov [ 10/Apr/14 ]

timegm patch and test results of mongodb 2.6 on solaris

Comment by Davide Italiano [ 04/Apr/14 ]

Solaris is 100% POSIX compliant, I think this is true for Solaris 10 and (probably) for Solaris 11.
timegm() is not standardized by any means, quoting the FreeBSD manpage:

The timegm() function is not specified by any standard; its function can-
not be completely emulated using the standard functions described above.

and therefore is not portable and cannot be 100% mapped using POSIX API(s).

Comment by Shaun Verch [ 02/Apr/14 ]

The reason we used timegm in the first place can be seen here: http://linux.die.net/man/3/timegm

The example they show in that page for how to implement timegm in terms of mktime manipulates the "TZ" environment variable, which is not thread safe. schwerin, am I remembering this correctly?

The manual for Solaris has mktime: http://docs.oracle.com/cd/E26502_01/html/E29034/mktime-3c.html#scrolltoc and gmtime: http://docs.oracle.com/cd/E26502_01/html/E29034/gmtime-3c.html#scrolltoc but does not seem to have timegm or any references to it.

Comment by Eric Milkie [ 01/Apr/14 ]

That's a good find.

Turns out:
http://lists.illumos.org/pipermail/developer/2010-December/001061.html

"If you use this symbol in your programs, be aware that the resulting
binaries will probably not operate on Solaris or OpenSolaris."
As the post above implies, there is probably a preprocessor macro we can define to avoid unintentionally using the Illumos-specific functions.
Shaun, is there a viable alternative that we can use on Oracle Solaris?

Comment by Ernie Hershey [ 01/Apr/14 ]

Actually I don't think either solution will work.

1) The buildbot builder is using the same flavor of libc:

[admin@bs-smartos-x86-64-1 ~]$ nm /usr/lib/libc.so.1 | grep ILL
[9969]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.1
[9971]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.2
[9973]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.3
[9976]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.4
[9978]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.5
[9979]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.6
[9983]  |         0|         0|OBJT |GLOB |0    |ABS    |ILLUMOS_0.7
[2882]  |    929313|        20|OBJT |LOCL |0    |18     |STR_SIGILL
[2887]  |    929397|         7|OBJT |LOCL |0    |18     |STR_SIGKILL
[admin@bs-smartos-x86-64-1 ~]$

2) In 2.6, "timegm" is dependent on the illumos symbol.

-bash-4.2# /usr/gnu/i386-pc-solaris2.11/bin/objdump -T /data/mongodb-sunos5-x86_64-67ec5c5b2926b682db1e21c22b1878043438827c-2014-04-01/bin/mongod | grep ILL
0000000000a75b50      DF *UND*  0000000000000000  ILLUMOS_0.1 timegm
-bash-4.2# 

3) in 2.4, nothing is dependent on the symbol.

-bash-4.2# /usr/gnu/i386-pc-solaris2.11/bin/objdump -T /data/mongodb-sunos5-x86_64-v2.4-2014-04-01/bin/mongod | grep ILL
-bash-4.2# 

4) We introduced timegm to the code in December in master.

[ernie@eahmba4 mongo]$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
[ernie@eahmba4 mongo]$ git grep timegm
src/mongo/util/time_support.cpp:        resultMillis = (1000 * static_cast<unsigned long long>(timegm(&dateStruct))) + millis;
[ernie@eahmba4 mongo]$ git checkout v2.4
Switched to branch 'v2.4'
Your branch is up-to-date with 'origin/v2.4'.
[ernie@eahmba4 mongo]$ git grep timegm
[ernie@eahmba4 mongo]$ 

5) Maybe sverch knows more detail.

[ernie@eahmba4 mongo]$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
[ernie@eahmba4 mongo]$ git blame src/mongo/util/time_support.cpp | grep timegm
d9b651d1 (Shaun Verch    2013-12-25 00:11:59 -0800 603)         resultMillis = (1000 * static_cast<unsigned long long>(timegm(&dateStruct))) + millis;
[ernie@eahmba4 mongo]$ 

Comment by Ernie Hershey [ 01/Apr/14 ]

As a last resort, I think so. The environments aren't very different though. We should also be able to figure out what's different about the buildbot build environment and replicate it in MCI. They're both using libc's with ILLUMOS version symbols and similar gcc versions, but the buildbot gcc looks like it's joyent's but the mci one is from the built in OmniOS packaging repo.

Comment by Eric Milkie [ 01/Apr/14 ]

Can we possibly use the buildbot SmartOS instance to build a 2.6 binary by hand when we release 2.6, until we solve the problem on the new MCI host? That could buy us some time.

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