Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8441] swift-corelibs-foundation: NSDateComponents.hash traps with overflow errors #3655

Closed
lorentey opened this issue Aug 1, 2018 · 3 comments
Assignees

Comments

@lorentey
Copy link
Member

lorentey commented Aug 1, 2018

Previous ID SR-8441
Radar None
Original Reporter @lorentey
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @lorentey
Priority Medium

md5: 1bfc6e33111ae4d440f01f3223dfb22a

Issue Description:

import Foundation

let d = NSDateComponents()
d.year = 2018
d.month = 8
d.day = 1
print(d.hash) // Traps with overflow error

@lorentey
Copy link
Member Author

lorentey commented Aug 1, 2018

NSCalendar.swift includes the following expression in NSDateComponent.hash:

        return calHash + (32832013 * (y + yy) + 2678437 * m + 86413 * d + 3607 * h + 61 * mm + s) + (41 * weekOfYear + 11 * weekOfMonth + 7 * weekday + 3 * weekdayOrdinal + quarter) * (1 << 5)

@lorentey
Copy link
Member Author

lorentey commented Aug 2, 2018

Fix is submitted in #1645

@spevans
Copy link
Collaborator

spevans commented Jan 25, 2019

Tested ok using swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a-ubuntu18.04

$ ~/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a-ubuntu18.04/usr/bin/swift
error: ld-2.27.so 0xffffffff0005c564: adding range [0x1464a-0x146ba) which has a base that is less than the function's low PC 0x14dc0. Please file a bug and attach the file at the start of this error message
error: ld-2.27.so 0xffffffff0005c564: adding range [0x146d0-0x146d6) which has a base that is less than the function's low PC 0x14dc0. Please file a bug and attach the file at the start of this error message
error: ld-2.27.so 0xffffffff0005c5c5: adding range [0x1464a-0x146ba) which has a base that is less than the function's low PC 0x14dc0. Please file a bug and attach the file at the start of this error message
error: ld-2.27.so 0xffffffff0005c5c5: adding range [0x146d0-0x146d6) which has a base that is less than the function's low PC 0x14dc0. Please file a bug and attach the file at the start of this error message
Welcome to Swift version 5.0-dev (LLVM f63b283c71, Clang 41ac4c4262, Swift 6875d77d6f).
Type :help for assistance.
  1> import Foundation 
  2. let d = NSDateComponents() 
  3. d.year = 2018 
  4. d.month = 8 
  5. d.day = 1 
  6. print(d.hash) // Traps with overflow error
-2947813404935422364
d: Foundation.NSDateComponents = {
  Foundation.NSObject = {}
  _calendar = nil
  _timeZone = nil
  _values = 19 values {
    [0] = 9223372036854775807
    [1] = 2018
    [2] = 8
    [3] = 1
    [4] = 9223372036854775807
    [5] = 9223372036854775807
    [6] = 9223372036854775807
    [7] = 9223372036854775807
    [8] = 9223372036854775807
    [9] = 9223372036854775807
    [10] = 9223372036854775807
    [11] = 9223372036854775807
    [12] = 9223372036854775807
    [13] = 9223372036854775807
    [14] = 9223372036854775807
    [15] = 9223372036854775807
    [16] = 9223372036854775807
    [17] = 9223372036854775807
    [18] = 9223372036854775807
  }
  timeZone = nil
}
  7>  

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants