Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None
    • Environment:

      MacBook Pro, Snow Leopard 10.6.2

      Description

      A user reported problems on IRC. It turns out that couchdb (or mochiweb) barfs when the local machine is set to some timezones.

      I set my local timezone to Western Indonesian Time (WIT) and reproduced the bug.

      Steps
      1) Change to WIT
      2) Visit Futon

      Error;

      {"error":"unknown_error","reason":"badarg"}

      and logs report;

      [info] [<0.104.0>] 127.0.0.1 - - 'GET' /_utils/index.html 500
      [error] [<0.112.0>] Badarg error in HTTP request
      [info] [<0.112.0>] Stacktrace: [{erlang,universaltime_to_localtime,[{{1969,12,31},{23,59,59}}]},

      {calendar,local_time_to_universal_time_dst,1}

      ,

      {httpd_util,rfc1123_date,1}

      ,

      {mochiweb_request,maybe_serve_file,3}

      ,

      {couch_httpd,serve_file,4}

      ,

      {couch_httpd,handle_request,5}

      ,

      {mochiweb_http,headers,5}

      ,

      {proc_lib,init_p_do_apply,3}

      ]

        Issue Links

          Activity

          Robert Newson created issue -
          Hide
          Robert Newson added a comment -

          This might even be an Erlang bug;

          1> httpd_util:rfc1123_date(erlang:localtime()).

            • exception error: bad argument
              in function erlang:universaltime_to_localtime/1
              called as erlang:universaltime_to_localtime(1969,12,31},{23,59,59)
              in call from calendar:local_time_to_universal_time_dst/1
              in call from httpd_util:rfc1123_date/1
              2>

          httpd_util:rfc1123_date declares it takes local time, but it blows up if you try it in the WIT timezone.

          Ooooops.

          Show
          Robert Newson added a comment - This might even be an Erlang bug; 1> httpd_util:rfc1123_date(erlang:localtime()). exception error: bad argument in function erlang:universaltime_to_localtime/1 called as erlang:universaltime_to_localtime( 1969,12,31},{23,59,59 ) in call from calendar:local_time_to_universal_time_dst/1 in call from httpd_util:rfc1123_date/1 2> httpd_util:rfc1123_date declares it takes local time, but it blows up if you try it in the WIT timezone. Ooooops.
          Hide
          Robert Newson added a comment -

          And Arabian Standard Time and East Africa Time...

          Show
          Robert Newson added a comment - And Arabian Standard Time and East Africa Time...
          Hide
          Paul Joseph Davis added a comment -

          Confirmed locally.

          Judging by erlang:universaltime_to_localtime(1969,12,31},{23,59,59) it looks like someone's date math is off by a second.

          Where do we file Erlang bugs?

          Show
          Paul Joseph Davis added a comment - Confirmed locally. Judging by erlang:universaltime_to_localtime( 1969,12,31},{23,59,59 ) it looks like someone's date math is off by a second. Where do we file Erlang bugs?
          Hide
          Paul Joseph Davis added a comment -

          Submitting to erlang-bugs@erlang.org. I'll post back if I hear anything.

          Show
          Paul Joseph Davis added a comment - Submitting to erlang-bugs@erlang.org. I'll post back if I hear anything.
          Hide
          Paul Joseph Davis added a comment -
          Show
          Paul Joseph Davis added a comment - Looks like the OTP team knows about it. http://www.erlang.org/cgi-bin/ezmlm-cgi?2:mss:1681:201001:jffdfifdokimdicjnpcp
          Hide
          James Clark added a comment -

          Get this with CouchDBX 1.0.0.8 (CouchDB 1.0 and Erlang R13B04) and Mac OS X 10.6.4 on Bangkok time (GMT +7).

          Show
          James Clark added a comment - Get this with CouchDBX 1.0.0.8 (CouchDB 1.0 and Erlang R13B04) and Mac OS X 10.6.4 on Bangkok time (GMT +7).
          Hide
          Paul Joseph Davis added a comment -

          This is a bug in the Erlang VM, not CouchDB

          Show
          Paul Joseph Davis added a comment - This is a bug in the Erlang VM, not CouchDB
          Paul Joseph Davis made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Invalid [ 6 ]
          Robert Newson made changes -
          Link This issue is duplicated by COUCHDB-1513 [ COUCHDB-1513 ]
          Robert Newson made changes -
          Resolution Invalid [ 6 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Assignee Robert Newson [ rnewson ]
          Hide
          Robert Newson added a comment -

          This was too silly to leave alone. I've modified our code to only ever use universal_time, avoiding the occasionally broken local<>universal conversion for specific timezones.

          Show
          Robert Newson added a comment - This was too silly to leave alone. I've modified our code to only ever use universal_time, avoiding the occasionally broken local<>universal conversion for specific timezones.
          Robert Newson made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Fix Version/s 1.3 [ 12318350 ]
          Resolution Fixed [ 1 ]
          Hide
          ASF subversion and git services added a comment -

          Commit 09b034911aed037839978d7e3f4905a4004fb74e in branch refs/heads/1696-update-mochiweb-2-4-2 from Robert Newson
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=09b0349 ]

          COUCHDB-627 - Support all timezones

          Forward-ported over top of MochiWeb 2.4.2, comprising specific chunks
          of b1a049bb, 445e919, 010522e, 317c97f lost during MochiWeb upgrade.

          Some timezones are incorrectly handled by OTP's calendar module. The
          ironic thing is that we only ever need the time in GMT (for HTTP
          response headers and the log file).

          This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses
          universal time everywhere, avoiding the broken conversion code.

          • Support all timezones for R14 series.
          • the _dst variant does exist in R14B04.
          • Fix local to universal handling.

          Also relates to COUCHDB-1513, a duplicate of COUCHDB-627.

          Show
          ASF subversion and git services added a comment - Commit 09b034911aed037839978d7e3f4905a4004fb74e in branch refs/heads/1696-update-mochiweb-2-4-2 from Robert Newson [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=09b0349 ] COUCHDB-627 - Support all timezones Forward-ported over top of MochiWeb 2.4.2, comprising specific chunks of b1a049bb, 445e919, 010522e, 317c97f lost during MochiWeb upgrade. Some timezones are incorrectly handled by OTP's calendar module. The ironic thing is that we only ever need the time in GMT (for HTTP response headers and the log file). This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses universal time everywhere, avoiding the broken conversion code. Support all timezones for R14 series. the _dst variant does exist in R14B04. Fix local to universal handling. Also relates to COUCHDB-1513 , a duplicate of COUCHDB-627 .
          Hide
          ASF subversion and git services added a comment -

          Commit cdf8949d341722423828471ca45d71f2fcb3a36d in branch refs/heads/master from Robert Newson
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=cdf8949 ]

          COUCHDB-627 - Support all timezones

          Forward-ported over top of MochiWeb 2.4.2, comprising specific chunks
          of b1a049bb, 445e919, 010522e, 317c97f lost during MochiWeb upgrade.

          Some timezones are incorrectly handled by OTP's calendar module. The
          ironic thing is that we only ever need the time in GMT (for HTTP
          response headers and the log file).

          This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses
          universal time everywhere, avoiding the broken conversion code.

          • Support all timezones for R14 series.
          • the _dst variant does exist in R14B04.
          • Fix local to universal handling.

          Also relates to COUCHDB-1513, a duplicate of COUCHDB-627.

          Show
          ASF subversion and git services added a comment - Commit cdf8949d341722423828471ca45d71f2fcb3a36d in branch refs/heads/master from Robert Newson [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=cdf8949 ] COUCHDB-627 - Support all timezones Forward-ported over top of MochiWeb 2.4.2, comprising specific chunks of b1a049bb, 445e919, 010522e, 317c97f lost during MochiWeb upgrade. Some timezones are incorrectly handled by OTP's calendar module. The ironic thing is that we only ever need the time in GMT (for HTTP response headers and the log file). This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses universal time everywhere, avoiding the broken conversion code. Support all timezones for R14 series. the _dst variant does exist in R14B04. Fix local to universal handling. Also relates to COUCHDB-1513 , a duplicate of COUCHDB-627 .
          Hide
          ASF subversion and git services added a comment -

          Commit d881aa324fa9be686ac4f6f60a59d86374a4f8ff in couchdb-mochiweb's branch refs/heads/1843-feature-bigcouch from Robert Newson
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-mochiweb.git;h=d881aa3 ]

          COUCHDB-627 - Support all timezones

          Some timezones are incorrectly handled by OTP's calendar module. The
          ironic thing is that we only ever need the time in GMT (for HTTP
          response headers and the log file).

          This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses
          universal time everywhere, avoiding the broken conversion code.

          Show
          ASF subversion and git services added a comment - Commit d881aa324fa9be686ac4f6f60a59d86374a4f8ff in couchdb-mochiweb's branch refs/heads/1843-feature-bigcouch from Robert Newson [ https://git-wip-us.apache.org/repos/asf?p=couchdb-mochiweb.git;h=d881aa3 ] COUCHDB-627 - Support all timezones Some timezones are incorrectly handled by OTP's calendar module. The ironic thing is that we only ever need the time in GMT (for HTTP response headers and the log file). This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses universal time everywhere, avoiding the broken conversion code.

            People

            • Assignee:
              Robert Newson
              Reporter:
              Robert Newson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development