Bug 1622 - ./waf --apiscan hangs waf
./waf --apiscan hangs waf
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: python bindings
pre-release
All All
: P3 normal
Assigned To: Gustavo J. A. M. Carneiro
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-10 11:02 EDT by Tom Henderson
Modified: 2013-11-19 14:44 EST (History)
1 user (show)

See Also:


Attachments
patch to fix (915 bytes, patch)
2013-11-12 15:47 EST, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Henderson 2013-04-10 11:02:40 EDT
./waf --apiscan will cause waf to hang, and the process must be killed.  This problem was apparently introduced with the recent change to waf-1.7.10.
Comment 1 Gustavo J. A. M. Carneiro 2013-04-10 11:09:37 EDT
I remember that WAF did not have any API you can call to "exit WAF right now", which we need to do[1] at the end of --apiscan.  I did some dirty hacks, changing some waf inner data structures, to try to cause it to exit, and is not surprising that my hacks stopped working.

[1] the reason is that to keep WAF going after apiscan we would need to tell it beforehand which files a task creates or modifies, which is very complicated to accomplish in the case of --apiscan.
Comment 2 Tom Henderson 2013-04-10 11:21:34 EDT
(In reply to comment #1)
> I remember that WAF did not have any API you can call to "exit WAF right now",
> which we need to do[1] at the end of --apiscan.  I did some dirty hacks,
> changing some waf inner data structures, to try to cause it to exit, and is not
> surprising that my hacks stopped working.
> 
> [1] the reason is that to keep WAF going after apiscan we would need to tell it
> beforehand which files a task creates or modifies, which is very complicated to
> accomplish in the case of --apiscan.

In this case, it is hanging before performing the scan.  

When I roll back to the version before waf was upgraded (1b5ccba50c6b) and I ask for an apiscan with the "-vvv" option, this kind of debugging output is generated:

08:14:17 envhash d751713988987e9331980363e24189ce []
08:14:17 envhash d751713988987e9331980363e24189ce []
08:14:17 envhash d751713988987e9331980363e24189ce []
08:14:17 envhash d751713988987e9331980363e24189ce []
api-scan-gcc_ILP32
api-scan-gcc_LP64
python-scan-collector
/usr/local/lib/python2.6/dist-packages/pygccxml/parser/declarations_cache.py:8: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
...

However, same command for the tip of ns-3-dev will cause waf to hang after these statements:

08:17:39 envhash d751713988987e9331980363e24189ce []
08:17:39 envhash d751713988987e9331980363e24189ce []
08:17:39 envhash d751713988987e9331980363e24189ce []

i.e. the display() method in bindings/python/wscript:
    def display(self):
        return 'api-scan-%s\n' % (self.target,)

is not invoked, seeming to imply that the task is not launched and perhaps there is some deadlock in task dispatching
Comment 3 Tom Henderson 2013-04-10 12:58:35 EDT
(In reply to comment #1)
> I remember that WAF did not have any API you can call to "exit WAF right now",
> which we need to do[1] at the end of --apiscan.  I did some dirty hacks,
> changing some waf inner data structures, to try to cause it to exit, and is not
> surprising that my hacks stopped working.
> 
> [1] the reason is that to keep WAF going after apiscan we would need to tell it
> beforehand which files a task creates or modifies, which is very complicated to
> accomplish in the case of --apiscan.

In light of the above, would it be easier to maintain, in the long run, a separate program to perform apiscan outside of waf?  e.g.

utils/apiscan.py --all
utils/apiscan.py --modules=lte
Comment 4 Gustavo J. A. M. Carneiro 2013-04-10 13:57:03 EDT
(In reply to comment #3)
> (In reply to comment #1)
> In light of the above, would it be easier to maintain, in the long run, a
> separate program to perform apiscan outside of waf?  e.g.
> 
> utils/apiscan.py --all
> utils/apiscan.py --modules=lte

One might think so, but then the apiscan.py script needs to know a bunch of things that is in the waf scripts in order to do its job, starting with with ns3 modules that exist, their dependencies (dependencies are very important), and compilation flags needed (gccxml is a real compiler, needs all the proper include paths set).
Comment 5 Mitch Watrous 2013-04-10 20:05:55 EDT
I tried to determine exactly which changeset introduced the problem, and
I was able to narrow it down to the changeset that contains the new version of waf or the one right after that.

The version before waf was upgraded does the binding scans fine:

    Improve logging of InetTopologyReader
    author	Vedran Miletić <rivanvx@gmail.com>
    	Mon, 01 Apr 2013 21:56:36 +0200 (9 days ago)
    changeset 9276	1b5ccba50c6b

The next change set, which upgraded waf, won't build for me:

    Upgrade waf to 1.7.10 and fix included wscripts
    author	Vedran Miletić <rivanvx@gmail.com>
    	Mon, 01 Apr 2013 22:33:46 +0200 (9 days ago)
    changeset 9277	0f87d1cb030c

The change set right after that builds but hangs during bindings scans:

    Fix Python bindings and openflow for waf 1.7.10 upgrade and 
          take care about boost requirements globally
    author	Alexander Afanasyev <alexander.afanasyev@ucla.edu>
    	Mon, 01 Apr 2013 22:34:50 +0200 (9 days ago)
    changeset 9278	0a749c0f1afd
Comment 6 Tom Henderson 2013-04-20 12:07:50 EDT

*** This bug has been marked as a duplicate of bug 1562 ***
Comment 7 Tom Henderson 2013-05-10 02:19:50 EDT
moving priority to P2 critical
Comment 8 Gustavo J. A. M. Carneiro 2013-10-13 13:00:23 EDT
--apiscan should no longer hang.  Instead I gave up in trying to make the WAF build exit early, and the build simply continues after the scanning.  At least it's less annoying.
Comment 9 Tom Henderson 2013-11-05 16:38:04 EST
(In reply to comment #8)
> --apiscan should no longer hang.  Instead I gave up in trying to make the WAF
> build exit early, and the build simply continues after the scanning.  At least
> it's less annoying.

I found a small problem with the current solution.  apiscan_task.run() will only run if there have been changes to the ns-3 source or wscripts.  It seems that perhaps this is because there is some check elsewhere in the system that suppresses build tasks if there are no code changes.  Can this be tweaked so that apiscan_task.run() is always called if --apiscan is passed as a waf argument?

To reproduce:  './waf --apiscan=all' will either scan zero or one modules.
Comment 10 Tom Henderson 2013-11-12 15:47:50 EST
Created attachment 1705 [details]
patch to fix

This works for me and will add to ns-3.18 repository for now; OK to commit to ns-3-dev?
Comment 11 Gustavo J. A. M. Carneiro 2013-11-12 18:29:36 EST
(In reply to Tom Henderson from comment #10)
> Created attachment 1705 [details]
> patch to fix
> 
> This works for me and will add to ns-3.18 repository for now; OK to commit
> to ns-3-dev?

Looks great.
Comment 12 Tom Henderson 2013-11-19 14:44:20 EST
this patch was applied in 10398:458687e0055d