Bug 217105 - [New Port]: devel/memleax Debugs memory leak of a running process by attaching it, without recompiling or restarting.
Summary: [New Port]: devel/memleax Debugs memory leak of a running process by attachin...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tobias Kortkamp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-14 19:45 UTC by Guy Tabrar
Modified: 2017-02-22 20:23 UTC (History)
2 users (show)

See Also:


Attachments
old memleax.shar (2.38 KB, application/x-shar)
2017-02-14 19:45 UTC, Guy Tabrar
no flags Details
memleax.shar (2.32 KB, application/x-shar)
2017-02-15 18:06 UTC, Guy Tabrar
no flags Details
devel___memleax.org (15.05 KB, text/plain)
2017-02-15 18:09 UTC, Guy Tabrar
no flags Details
memleax.shar (2.37 KB, application/x-shar)
2017-02-15 18:47 UTC, Guy Tabrar
no flags Details
devel___memleax.org (15.02 KB, text/plain)
2017-02-15 18:47 UTC, Guy Tabrar
no flags Details
memleax.shar (2.59 KB, application/x-shar)
2017-02-21 19:14 UTC, Guy Tabrar
no flags Details
memleax.shar (2.23 KB, application/x-shar)
2017-02-22 17:26 UTC, Guy Tabrar
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Tabrar 2017-02-14 19:45:00 UTC
Created attachment 179996 [details]
old memleax.shar
Comment 1 Guy Tabrar 2017-02-15 18:06:49 UTC
Created attachment 180020 [details]
memleax.shar
Comment 2 Guy Tabrar 2017-02-15 18:09:23 UTC
Created attachment 180021 [details]
devel___memleax.org

Synth log showing the port builds to a pkg without issue
Comment 3 Guy Tabrar 2017-02-15 18:11:00 UTC
Fixed some issues - confirmed syntax OK with portlint and checked it builds a pkg with synth.
Comment 4 Guy Tabrar 2017-02-15 18:47:02 UTC
Created attachment 180023 [details]
memleax.shar
Comment 5 Guy Tabrar 2017-02-15 18:47:48 UTC
Created attachment 180024 [details]
devel___memleax.org
Comment 6 Tobias Kortkamp freebsd_committer freebsd_triage 2017-02-20 18:59:20 UTC
Hi Guy,

there are still some minor problems with this.  If you fix them I'll
submit the port for review, and commit it :)

- There are still some Portlint warnings that need to be fixed (use
  portlint -A to get additional warnings, see [1]):

	WARN: /usr/home/tobias/Downloads/memleax/pkg-plist: There are
	only 2 items in the plist.  Consider using PLIST_FILES instead
	of pkg-plist when installing less than 6 items.
	FATAL: Makefile: [10]: use a tab (not space) after a variable name
	...
	8 fatal errors and 1 warning found.

- The v in PORTVERSION is wrong.  Use DISTVERSIONPREFIX if the version
  (GitHub tag) is prefixed by something else  
- GH_PROJECT is unnecessary when PORTNAME is the same
- Indent with one tab only after variable names
- It is shorter to do the installation manually like this:

  do-install:
	${INSTALL_PROGRAM} ${WRKSRC}/memleax ${STAGEDIR}${PREFIX}/bin
	${INSTALL_MAN} ${WRKSRC}/memleax.1 ${STAGEDIR}${PREFIX}/man/man1

- Use PLIST_FILES instead of pkg-plist since the port only installs 2 files:

  PLIST_FILES=	bin/memleax \
		man/man1/memleax.1.gz

- I don't think I can get the pkg-descr past my mentors.  Can you
  describe memleax in slightly more detail here?
  
- devel/libdwarf does not provide libdwarf.so but only provides a
  static library libdwarf.a, so the LIB_DEPENDS line for it is
  probably wrong.  The README claims that memleax will work with
  ports' libdwarf only [2].  Is this true or will it work fine with
  base's version?

[1] https://www.freebsd.org/doc/en/books/porters-handbook/testing-portlint.html
[2] https://github.com/WuBingzheng/memleax#build-from-source
Comment 7 Guy Tabrar 2017-02-21 04:51:27 UTC
(In reply to Tobias Kortkamp from comment #6)

Hi Tobias,

Wow - thanks for the detailed response. This is my first attempt at a port so I really appreciate it :)

I will try to address all of these issues later today.

Cheers,

Guy
Comment 8 Guy Tabrar 2017-02-21 19:14:44 UTC
Created attachment 180201 [details]
memleax.shar
Comment 9 Guy Tabrar 2017-02-21 19:17:11 UTC
(In reply to Tobias Kortkamp from comment #6)
Hi Tobias,

I think I have addressed everything you mentioned. I've uploaded the fixed memleax.shar.

Thanks!

Guy
Comment 10 Tobias Kortkamp freebsd_committer freebsd_triage 2017-02-21 20:26:24 UTC
(In reply to Guy Tabrar from comment #9)
Looks mostly good so far :)  While test building I've noticed two more problems:

- The pkg-message seems a bit redundant to me.  MAINTAINER already
  implies as much.

- Some Poudriere test builds fail:

FreeBSD 11.0/i386:
===>  Configuring for memleax-1.0.2
checking OS and machine type...
Error: unsupported machine type: i386. Only amd64 is supported.
===>  Script "configure" failed unexpectedly.

FreeBSD 10.3/i386 and FreeBSD 10.3/amd64:
===>  Configuring for memleax-1.0.2
checking OS and machine type...
on FreeBSD.
checking libraries...
checking libunwind...
checking libelf...
checking libdw...
libdw-devel is missing.
checking libdwarf...
libdwarf is missing.
Error: libdw or libdwarf is required.
Try '--disable-debug_line' to disable it.
===>  Script "configure" failed unexpectedly.

It's fine on FreeBSD 11.0/amd64.

- The configure script seems to explicitly check for an amd64 host.
  Should ONLY_FOR_ARCHS just be amd64?
Comment 11 Guy Tabrar 2017-02-22 17:26:23 UTC
Created attachment 180223 [details]
memleax.shar
Comment 12 Guy Tabrar 2017-02-22 17:27:00 UTC
(In reply to Tobias Kortkamp from comment #10)
Hi Tobias,

Thanks for your patience with me. I have built a 10.3 machine so I can test and addressed all the issues you raised (I hope!).

Regarding whether it should be amd64 only, yes I think this is correct. I guess I will need to setup Poudriere for any future porting adventures :)

Cheers,

Guy
Comment 13 Tobias Kortkamp freebsd_committer freebsd_triage 2017-02-22 18:07:12 UTC
(In reply to Guy Tabrar from comment #12)

> Thanks for your patience with me. I have built a 10.3 machine so I can test and addressed all the issues you raised (I hope!).

Yep, it builds fine now :).  I've submitted it for review (https://reviews.freebsd.org/D9725) and can probably commit it soon.

> Regarding whether it should be amd64 only, yes I think this is correct. I guess I will need to setup Poudriere for any future porting adventures :)

Poudriere definitely helps avoid lots of extra work ;)
Comment 14 commit-hook freebsd_committer freebsd_triage 2017-02-22 20:18:58 UTC
A commit references this bug:

Author: tobik
Date: Wed Feb 22 20:18:10 UTC 2017
New revision: 434637
URL: https://svnweb.freebsd.org/changeset/ports/434637

Log:
  New port: devel/memleax

  Memleax debugs memory leaks of running processes by attaching to them,
  without recompiling or restarting. It hooks the target process's invocation
  of memory allocation and free and reports the memory blocks which live
  long enough as memory leak, in real time.

  It is convenient to use, and suitable for production environments.
  There is no need to recompile the program or restart the target process.
  You can run memleax to monitor the target process, wait for the real-time
  memory leak report, and then kill it with ctrl-c to stop monitoring.

  WWW: https://github.com/WuBingzheng/memleax

  PR:		217105
  Submitted by:	Guy Tabrar <guy.tabrar@me.com>
  Approved by:	lme (mentor)
  Differential Revision:	https://reviews.freebsd.org/D9725

Changes:
  head/devel/Makefile
  head/devel/memleax/
  head/devel/memleax/Makefile
  head/devel/memleax/distinfo
  head/devel/memleax/pkg-descr
Comment 15 Tobias Kortkamp freebsd_committer freebsd_triage 2017-02-22 20:23:29 UTC
... and committed with the following minor changes:

- Add missing LICENSE_FILE
- Slight change in the COMMENT
- Capitalized the first memleax in the pkg-descr