Bug 196668 - sysutils/logrotate: segmentation fault due to differences in qsort_r implementations
Summary: sysutils/logrotate: segmentation fault due to differences in qsort_r implemen...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Guido Falsi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-13 04:23 UTC by jyoung15
Modified: 2015-05-14 07:52 UTC (History)
4 users (show)

See Also:
js: maintainer-feedback+


Attachments
qsort_r patch (896 bytes, patch)
2015-01-13 04:25 UTC, jyoung15
no flags Details | Diff
Update port to version 3.8.9 (2.42 KB, patch)
2015-02-20 12:42 UTC, Anton Yuzhaninov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jyoung15 2015-01-13 04:23:47 UTC
sysutils/logrotate 3.8.8 causes a segmentation fault.  SVN r450 upstream introduced sortGlobResult, which uses qsort_r.  Linux and FreeBSD have different implementations of this function:

Linux:
     void qsort_r(void *base, size_t nmemb, size_t size,
                  int (*compar)(const void *, const void *, void *),
                  void *arg);
FreeBSD:
     void qsort_r(void *base, size_t nmemb, size_t size, void *thunk,
                  int (*compar)(void *, const void *, const void *));


Note differences in location of thunk/arg and compar function pointer. Proposed patch attached.
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2015-01-13 04:23:47 UTC
Maintainer CC'd
Comment 2 jyoung15 2015-01-13 04:25:13 UTC
Created attachment 151520 [details]
qsort_r patch
Comment 3 js 2015-01-14 23:57:58 UTC
First off, well done, good catch. I'd use tab indentation instead of the two spaces, that's all.

Here we don't have to maintain cross-platform functionality, nevertheless it would be a good idea to report this problem upstream too.
Comment 4 jyoung15 2015-02-10 12:56:40 UTC
Issue will be resolved upstream in 3.8.9.  See https://fedorahosted.org/logrotate/ticket/48 for details.
Comment 5 Anton Yuzhaninov 2015-02-20 12:42:30 UTC
Created attachment 153206 [details]
Update port to version 3.8.9

Update port to version 3.8.9. While here fix some portlint warnings.
Comment 6 Anton Yuzhaninov 2015-02-20 14:01:34 UTC
My patch tested with poudriere on i386/amd64:
http://citrin.ru/tmp/logrotate-3.8.9-poudriere-logs.tgz
Comment 7 js 2015-02-20 18:33:03 UTC
Anton,

This is wonderful. I couldn't set up a VM to test it out yet, but this is unrelated to this bug.

Maybe we should build this port by its supported way, running autogen.sh, configure, and make.
Comment 8 Anton Yuzhaninov 2015-03-17 10:36:41 UTC
FreeBSD ports has broken logrotate version for a very long time. This affects many FreeBSD users.
I think port first should be updated to 3.8.9 and only then changed to running autogen.sh is this way has visible advantages.
Comment 9 Doug Luce 2015-05-05 02:58:26 UTC
I tried both Jason's patch to 3.8.8 and Anton's upgrade to 3.8.9, and both work well for me (segfault is gone).

Jul, I'd urge going ahead with the 3.8.9 upgrade and plan on moving to the supported build at a later time.  The port as it stands now is broken.

Thanks,

Doug
Comment 10 Guido Falsi freebsd_committer freebsd_triage 2015-05-13 22:21:22 UTC
Maintainer approved, will commit after some final testing.
Comment 11 Guido Falsi freebsd_committer freebsd_triage 2015-05-14 07:51:43 UTC
Committed. Thanks!
Comment 12 commit-hook freebsd_committer freebsd_triage 2015-05-14 07:52:07 UTC
A commit references this bug:

Author: madpilot
Date: Thu May 14 07:51:11 UTC 2015
New revision: 386301
URL: https://svnweb.freebsd.org/changeset/ports/386301

Log:
  - Update to 3.8.9
  - Add LICENSE
  - Use @sample in plist
  - While here, regenerate patches to silence portlint warnings

  PR:		196668
  Submitted by:	jyoung15 at gmail.com
  Approved by:	Balazs Nagy <js at iksz.hu> (maintainer)

Changes:
  head/sysutils/logrotate/Makefile
  head/sysutils/logrotate/distinfo
  head/sysutils/logrotate/files/patch-Makefile
  head/sysutils/logrotate/files/patch-config.c
  head/sysutils/logrotate/files/patch-config.h
  head/sysutils/logrotate/files/patch-logrotate.8
  head/sysutils/logrotate/files/patch-logrotate.c
  head/sysutils/logrotate/pkg-plist