Bug 235297 - devel/ElectricFence: posix_memalign() missing
Summary: devel/ElectricFence: posix_memalign() missing
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: Kurt Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-29 14:12 UTC by topical
Modified: 2019-02-26 22:29 UTC (History)
1 user (show)

See Also:


Attachments
Found this patch in the net and it works. Not sure about the author. (1.01 KB, patch)
2019-01-29 14:14 UTC, topical
no flags Details | Diff
patch to add posix_memalign() (1.19 KB, patch)
2019-02-10 21:40 UTC, topical
no flags Details | Diff
patch-v2 (2.99 KB, patch)
2019-02-22 06:18 UTC, Kurt Jaeger
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description topical 2019-01-29 14:12:43 UTC
The current implementation doesn't handle posix_memalign(). 

Programs using posix_memalign() to allocate memory effectively silently fall back to the standard implementation. Whenever the program calls free() to release the memory, the efence implementation is called and barfs that the memory is unknown, leading to a core dump.

Sadly, many programs use posix_memalign and thus cannot be debugged with efence.
Comment 1 topical 2019-01-29 14:14:39 UTC
Created attachment 201507 [details]
Found this patch in the net and it works. Not sure about the author.
Comment 2 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-10 12:37:32 UTC
Can you provide the link (source) of the patch ?
Comment 3 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-10 12:39:55 UTC
I checked the attachment, patch is not complete (lines are missing), can you re-upload ?
Comment 4 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-10 12:43:19 UTC
Can you also provide a testcase, name a program that can not be debugged
with efence ?
Comment 5 topical 2019-02-10 21:38:19 UTC
I found the patch at Redhat Bug 603075, see https://bugzilla.redhat.com/show_bug.cgi?id=603075

But according to the timestamp, the patch is much older. I found an older version at https://launchpad.net/ubuntu/+source/electric-fence/+changelog but I couldn't trace the  referenced bug, but according to change log it seems that the patch was contributed by Petr Machata.
Comment 6 topical 2019-02-10 21:40:08 UTC
Created attachment 201907 [details]
patch to add posix_memalign()
Comment 7 topical 2019-02-10 21:40:52 UTC
Ups - patch should be complete now.
Comment 8 topical 2019-02-10 21:44:27 UTC
E.g. nginx uses posix_memalign() for its memory pool. With the patch, I could solve bug #235296.
Comment 9 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-22 06:18:08 UTC
Created attachment 202250 [details]
patch-v2

Rearranged for portlint happyness, pkg-plist fixes. testbuilds are fine.

Waiting for maintainer approval.
Comment 10 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-22 06:19:13 UTC
Ups, sorry, wrong PR!
Comment 11 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-22 06:19:40 UTC
Comment on attachment 202250 [details]
patch-v2

wrong PR for this patch.
Comment 12 topical 2019-02-26 16:28:56 UTC
Is there anything else I can do?
Comment 13 Kurt Jaeger freebsd_committer freebsd_triage 2019-02-26 22:28:56 UTC
Committed, thanks!
Comment 14 commit-hook freebsd_committer freebsd_triage 2019-02-26 22:29:16 UTC
A commit references this bug:

Author: pi
Date: Tue Feb 26 22:28:53 UTC 2019
New revision: 493985
URL: https://svnweb.freebsd.org/changeset/ports/493985

Log:
  devel/ElectricFence: add missing posix_memalign()

  The current implementation did not handle posix_memalign().

  Programs using posix_memalign() to allocate memory effectively
  silently fall back to the standard implementation. Whenever the
  program calls free() to release the memory, the efence implementation
  is called and barfs that the memory is unknown, leading to a core
  dump.

  Sadly, many programs use posix_memalign and thus could not be debugged
  with efence.

  Example use case: See nginx, PR#235296

  PR:		235297
  Submitted by:	topical@gmx.net
  Obtained from:	https://bugzilla.redhat.com/show_bug.cgi?id=603075
  		https://launchpad.net/ubuntu/+source/electric-fence/+changelog

Changes:
  head/devel/ElectricFence/files/patch-efence.c