NSLog uses wrong value as thread ID
| Originator: | jthywissen | ||
| Number: | rdar://15557367 | Date Originated: | 28-Nov-2013 08:05 AM |
| Status: | Open | Resolved: | |
| Product: | OS X | Product Version: | OS X 10.9 (13A603) |
| Classification: | UI/Usability | Reproducible: | Always |
Summary: NSLog, when it reports a log entry to stderr and ASL, uses the wrong values as the thread ID. This confounds debugging, since tools such as lldb, sample, spindump, Activity Monitor, etc, use the actual thread ID. (NSLog reports the Mach thread self port name in hex, instead of the thread ID in decimal.) Steps to Reproduce: 1. Observe stderr of any program that writes to NSLog. Log entries are formatted as: date time progname[pid:tid] message. Note the tid. 2. Debug the same program in lldb (aka Xcode debugger). Run the lldb command "thread list". Note the tids. 3. Observe the same program in Activity Monitor, sample, or spindump. Note the thread IDs. Expected Results: Thread IDs should be consistent and correct. Actual Results: lldb, sample, spindump, and Activity Monitor are consistent (although lldb reports tid in hexadecimal). NSLog inconsistent is with the other tools. Version: OS X 10.9 (13A603) Notes: Fix: In CoreFoundation, CFUtilities.c, lines 623 and 624 (as of CF-855.11): On both lines, change "pthread_mach_thread_np(pthread_self())" to "pthread_threadid_np(NULL, &pthreadThreadId)". And, while you're there, please change the format specifier "%x" to "%u" -- most other tools use decimal for thread ids, and the other fields in a log message (pid, for example) are decimal. Configuration: Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!