ncal crashes with segmentation fault

Bug #1549850 reported by bugproxy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GLibC
Unknown
Unknown
bsdmainutils (Ubuntu)
Fix Released
Undecided
Dimitri John Ledkov
glibc (Ubuntu)
Invalid
Undecided
Dimitri John Ledkov

Bug Description

== Comment: #0 - Christoph Arenz <email address hidden> - 2016-02-24 09:27:23 ==
The ncal calendar program crashes with a segmentation fault.

test@s8315043:~$ ncal
Segmentation fault (core dumped)

Note that ncal is a symlink to cal and cal is working fine.

test@s8315043:~$ ls -l /usr/bin/cal /usr/bin/ncal
lrwxrwxrwx 1 root root 4 Feb 7 11:08 /usr/bin/cal -> ncal
-rwxr-xr-x 1 root root 33888 Feb 7 11:08 /usr/bin/ncal

arenz@oc6366361507:~$ cal
    February 2016
Su Mo Tu We Th Fr Sa
    1 2 3 4 5 6
 7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29

gdb session shows:
(gdb) run
Starting program: /usr/bin/ncal

Program received signal SIGSEGV, Segmentation fault.
__wcslen (s=0x0) at wcslen.c:32
32 wcslen.c: No such file or directory.

== Comment: #3 - Christoph Arenz <email address hidden> - 2016-02-24 11:52:20 ==
Package information for ncal/cal:
test@s8315043:~$ dpkg -l bsdmainutils
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============================-====================-====================-==================================================================
ii bsdmainutils 9.0.6ubuntu2 s390x collection of more utilities from FreeBSD

Revision history for this message
bugproxy (bugproxy) wrote : sosreport

Default Comment by Bridge

tags: added: architecture-s39064 bugnameltc-137759 severity-medium targetmilestone-inin1604
Revision history for this message
bugproxy (bugproxy) wrote : dbginfo output

Default Comment by Bridge

Changed in ubuntu:
assignee: nobody → Skipper Bug Screeners (skipper-screen-team)
dann frazier (dannf)
affects: ubuntu → bsdmainutils (Ubuntu)
dann frazier (dannf)
Changed in bsdmainutils (Ubuntu):
status: New → Confirmed
Revision history for this message
dann frazier (dannf) wrote :

Thanks for the report. The problem appears to be with how glibc's nl_langinfo() is returning values on s390x (or, at least, with how ncal *assumes* it will return them). Here's a short test program:

---
int main() {
  int i = (intptr_t)nl_langinfo(_NL_TIME_WEEK_1STDAY);
  printf("1ST DAY IS %d\n", i);
}
---
On x86, this, for most locales, will output:

$ ./test
1ST DAY IS 19971130

However, on s390x, it outputs:

$ ./test
1ST DAY IS 0

However, if you look at the full pointer, you can see that s390x does have the correct value in the top order bytes:

ubuntu@s390x:~$ cat test.c
#include <stdio.h>
#include <langinfo.h>
#include <stdint.h>

int main() {
  char *p = nl_langinfo(_NL_TIME_WEEK_1STDAY);
  printf("1ST DAY IS %p\n", p);
}

ubuntu@s390x:~$ gcc test.c -o test
ubuntu@s390x:~$ ./test
1ST DAY IS 0x130bc3a00000000

While on x86/arm64 it is in the lower bytes:
ubuntu@x86$ ./test
1ST DAY IS 0x130bc3a

Changed in glibc (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Changed in bsdmainutils (Ubuntu):
assignee: Skipper Bug Screeners (skipper-screen-team) → Dimitri John Ledkov (xnox)
Changed in glibc (Ubuntu):
status: New → Invalid
Changed in bsdmainutils (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bsdmainutils - 9.0.6ubuntu3

---------------
bsdmainutils (9.0.6ubuntu3) xenial; urgency=medium

  * Fix ncal on big-endian platforms. LP: #1549850.

 -- Dimitri John Ledkov <email address hidden> Tue, 01 Mar 2016 11:34:26 +0000

Changed in bsdmainutils (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2016-03-08 09:01 EDT-------
Verified for bsdmainutils 9.0.6ubuntu3 on s390x.
ncal works now as expected. Thanks for fixing!
This bugzilla can be closed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.