Bug 208027 - misc/mc: 4.8.16 has undefined behavior in its code and gcc generates "ud2a" instruction to produce SIGILL in 9.x
Summary: misc/mc: 4.8.16 has undefined behavior in its code and gcc generates "ud2a" i...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Felder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-15 14:29 UTC by Eugene Grosbein
Modified: 2016-03-18 12:05 UTC (History)
3 users (show)

See Also:
woodsb02: maintainer-feedback+


Attachments
fix undefined behavior (347 bytes, patch)
2016-03-15 14:29 UTC, Eugene Grosbein
no flags Details | Diff
Patch from upstream ticket 3617 to fix SIGILL crash upon creating a file (39.76 KB, patch)
2016-03-17 22:56 UTC, Ben Woods
woodsb02: maintainer-approval+
Details | Diff
Patch from upstream ticket 3617 to fix SIGILL crash upon creating a file (40.11 KB, patch)
2016-03-17 22:58 UTC, Ben Woods
woodsb02: maintainer-approval+
Details | Diff
QA: Successful poudriere testport logs for misc/mc 4.8.16 with patch on FreeBSD 10.2 amd64 (178.62 KB, text/plain)
2016-03-17 22:59 UTC, Ben Woods
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2016-03-15 14:29:51 UTC
Created attachment 168240 [details]
fix undefined behavior

While building mc-4.8.16 under FreeBSD 9.x using system gcc 4.2.1,
one obtains a warning:

interface.c: In function 'mc_open':
interface.c:203: warning: 'mode_t' is promoted to 'int' when passed through '...'
interface.c:203: warning: (so you should pass 'int' not 'mode_t' to 'va_arg')
interface.c:203: note: if this code is reached, the program will abort
interface.c:203: warning: will never be executed

gcc generates instruction "ud2a" for the code and mc crashes with SIGILL when it calls mc_open() function to create a file, e.g. while copying a file to another directory or saving a file in the mcedit.

A patch is attached.
Comment 1 Eugene Grosbein 2016-03-15 14:44:51 UTC
The problem and patch reported upstream:
https://www.midnight-commander.org/ticket/3617
Comment 2 Ben Woods freebsd_committer freebsd_triage 2016-03-17 20:58:17 UTC
Comment on attachment 168240 [details]
fix undefined behavior

The patch associated with the upstream ticket 3617 has been updated. Rejecting this patch in favour of using the new one from upstream.
Comment 3 Ben Woods freebsd_committer freebsd_triage 2016-03-17 22:56:12 UTC
Created attachment 168339 [details]
Patch from upstream ticket 3617 to fix SIGILL crash upon creating a file

Note that this patch was generated by comparing the resulting mc-4.8.16.tar.xz files when following the mc release building guidelines, with a stock 4.8.16 release, and the 4.8.16 release with the patch applied from upstream ticket 3617 "3617-mc_open-handle-varargs-mode_t-promotion-issue--v2.patch".

mc release building guidelines:
https://www.midnight-commander.org/wiki/ReleaseGuidelines
Comment 4 Ben Woods freebsd_committer freebsd_triage 2016-03-17 22:58:10 UTC
Created attachment 168340 [details]
Patch from upstream ticket 3617 to fix SIGILL crash upon creating a file

Patch updated to bump PORTREVISION
Comment 5 Ben Woods freebsd_committer freebsd_triage 2016-03-17 22:59:32 UTC
Created attachment 168341 [details]
QA: Successful poudriere testport logs for misc/mc 4.8.16 with patch on FreeBSD 10.2 amd64
Comment 6 Lena 2016-03-17 23:09:03 UTC
If you patch mc 4.8.16 in the FreeBSD port then please also fix another new bug (syntax error) in 4.8.16 with the patch
https://www.midnight-commander.org/attachment/ticket/3611/mc-3611-fish-fix-perl-ls-helper.patch
Comment 7 Ben Woods freebsd_committer freebsd_triage 2016-03-18 06:06:47 UTC
(In reply to Lena from comment #6)
Hi Lena, thanks for your comment. I have raised a separate bug report for that issue here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208104
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-03-18 12:04:58 UTC
A commit references this bug:

Author: feld
Date: Fri Mar 18 12:04:33 UTC 2016
New revision: 411345
URL: https://svnweb.freebsd.org/changeset/ports/411345

Log:
  misc/mc: Multiple fixes

  - Fix subshell functionality for csh users
  - Make SFTP an option, enabled by default
  - Fix SIGILL on FreeBSD 9.x
  - Fix perl ls helper with fish shell

  PR:		207487, 208027, 208102, 208104

Changes:
  head/misc/mc/Makefile
  head/misc/mc/files/patch-upstreamticket2742-detect-csh-as-tcsh-by-name.patch
  head/misc/mc/files/patch-upstreamticket3611-fish-fix-perl-ls-helper.patch
  head/misc/mc/files/patch-upstreamticket3617-mc_open-handle-varargs-mode_t-promotion-issue--v2.patch
Comment 9 Mark Felder freebsd_committer freebsd_triage 2016-03-18 12:05:46 UTC
Committed, thanks!