Re: infinite-loop compilng for 64bit target (32bit works fine)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: infinite-loop compilng for 64bit target (32bit works fine)

Harro Verkouter

Hi all,

Suddenly I realised I completely forgot to attach the file with output
and systemdetails with my mail of last week about this problem.

I suspect this infinite loop whilst compiling for a 64bit target problem
is mainly g++'s problem, however....

If I send the same mail off to gcc's buglist, I suspect I get the same
amount of feedback since, most likely, the gcc developers' attitude
would be "it's spirit's problem because it's not 64bit clean" so this
would also cause also infinite loop.

IMHO it is a case of 'destructive interference' - some constructs in
spirit might trigger a 64bit-problem in gcc ...

I would appreciate any help in getting a bit more info out of either
spirit or g++ since at the moment I don't know where to look or how to
produce something to look at...

This time, let me not forget to attach the file. For completeness
(apologies if you see it again) I'll attach the source-file as well.

Cheers and thanks in advance,

Harro Verkouter


Script started on Fri Sep  9 16:05:31 2005

bash-2.05a$ uname -a
Linux beosrv 2.4.25 #2 SMP Fri Mar 12 21:19:58 CET 2004 x86_64 GNU/Linux


bash-2.05a$ /usr/bin/g++ -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.2/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.2 (Debian)


bash-2.05a$ time /usr/bin/g++ -fPIC -g -Wall -W -Werror -fexceptions -ftemplate-depth-35 -D_REENTRANT -DBUILDTIME="Friday 09 September 2005/15:36:01" -D_POSIX_PTHREAD_SEMANTICS -m32 -I/jop200_0/verkout/pci/thirdparty/spirit-1.8.3/miniboost -I/jop200_0/verkout/pci/thirdparty/spirit-1.8.3 -o infinite-loop32 infinite-loop.cc

real 0m4.393s
user 0m3.860s
sys 0m0.250s



bash-2.05a$ time /usr/bin/g++ -fPIC -g -Wall -W -Werror -fexceptions -ftemplate-depth-35 -D_REENTRANT -DBUILDTIME="Friday 09 September 2005/15:36:01" -D_POSIX_PTHREAD_SEMANTICS -m64 -I/jop200_0/verkout/pci/thirdparty/spirit-1.8.3/miniboost -I/jop200_0/verkout/pci/thirdparty/spirit-1.8.3 -o infinite-loop64 infinite-loop.cc

<<< control-C after [see below] some 4 1/2 minutes of 99.9% CPU-time >>>

real 4m30.275s
user 0m0.000s
sys 0m0.010s

bash-2.05a$ ./infinite-loop32
Enter a list of numbers/ranges: 30-33,5,2,22,19-22
You entered:
2,5,19,20,21,22,30,31,32,33,

bash-2.05a$ exit
exit

Script done on Fri Sep  9 16:11:19 2005

#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>

#include <boost/spirit/core.hpp>
#include <boost/spirit/utility.hpp>
#include <boost/spirit/symbols.hpp>


using namespace std;
using namespace boost::spirit;

//
// The grammar for a list of ints
//
struct ilist_grammar:
        public grammar<ilist_grammar>
{
        template <typename ScannerT>
        struct definition
        {
                rule<ScannerT>    line, range, entry;
               
                definition( ilist_grammar const& self )
                {
                        range       = (int_p[assign(self.r_start)] >> '-'
                                                        >> int_p[assign(self.r_end)])[self.ranger];
                        // if the int_p is parsed, the integer
                        // is automagically appended to the list
                        entry       = range|int_p[append(self.iList)];
                        line        = entry >> *(',' >> entry);
                }

                rule<ScannerT> const& start( void ) const
                {
                        return line;
                }
        };


        struct ranger_t
        {
                // we don't actually use the iterators (in this case)
                // this is supposed to be trigger when a range is parsed
                // and this will append the range to the result and
                // clear the range for the next range
                template <typename IteratorT>
                void operator()( IteratorT , IteratorT ) const
                {
                        if( parent )
                        {
                                while( parent->r_start<=parent->r_end )
                                {
                                        parent->iList.push_back(parent->r_start);
                                        ++parent->r_start;
                                }
                                // reset
                                parent->r_start = 0;
                                parent->r_end   = 0;
                        }
                        return;
                }

                ranger_t() :
                        parent( 0 )
                {
                }

                ranger_t( ilist_grammar* p ) :
                        parent( p )
                {
                }

                ilist_grammar*   parent;
        };

        mutable int         r_start, r_end;
        // this functor is used to be able to process a parsed range
        // the void operator()( iterator start, iterator end ) const
        // is called - this method will process the range
        mutable ranger_t    ranger;
        mutable vector<int> iList;

        ilist_grammar() :
                ranger( this )
        {
        }
};

//
// this parses a list of integers and ranges of integers
// into a vector.
// However, the vector is first uniquefied and then
// sorted.
//
bool parse_list( const char* s, vector<int>& v )
{
        bool           rv;
        ilist_grammar  lg;
               
        if( (rv=parse(s, lg, space_p).full)==true )
        {
                vector<int>::iterator  uniqptr;

                v = lg.iList;

                // sort + make unique?
                sort( v.begin(), v.end() );

                uniqptr = unique( v.begin(), v.end() );

                v.erase( uniqptr, v.end() );
        }
        return rv;
}

int main( int , char** )
{
        string      s;
        vector<int> vi;

        cout << "Enter a list of numbers/ranges: ";
        cin >> s;

        if( !parse_list(s.c_str(), vi) )
        {
                cout << "Syntax error." << endl;
                return -1;
        }
        cout << "You entered:\n";
        copy(vi.begin(), vi.end(), ostream_iterator<int>(cout, ","));

        return 0;
}

Reply | Threaded
Open this post in threaded view
|

Re: infinite-loop compilng for 64bit target (32bit works fine)

Joel de Guzman-2
Harro Verkouter wrote:

>
> Hi all,
>
> Suddenly I realised I completely forgot to attach the file with output
> and systemdetails with my mail of last week about this problem.
>
> I suspect this infinite loop whilst compiling for a 64bit target problem
> is mainly g++'s problem, however....
>
> If I send the same mail off to gcc's buglist, I suspect I get the same
> amount of feedback since, most likely, the gcc developers' attitude
> would be "it's spirit's problem because it's not 64bit clean" so this
> would also cause also infinite loop.
>
> IMHO it is a case of 'destructive interference' - some constructs in
> spirit might trigger a 64bit-problem in gcc ...
>
> I would appreciate any help in getting a bit more info out of either
> spirit or g++ since at the moment I don't know where to look or how to
> produce something to look at...
>
> This time, let me not forget to attach the file. For completeness
> (apologies if you see it again) I'll attach the source-file as well.

Hi Harro,

The biggest problem is that I do not have access to a 64bit gcc
compiler. I have some thughts that might or might not be helpful.
Compiler bugs typically happen with optimization. Have you tried
turning those off and does it still loop forever? If yes, then
there's a good chance that it's a Spirit 64-bit bug. Also, have
you tried to use spirit's debug mode and see which rule(s) are
causing the infinite loop? Finally, you can use a debugger and
step through the code to see what's happening in micro detail.
I know this is not much of a help, but...

Regards,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: infinite-loop compilng for 64bit target (32bit works fine)

João Abecasis-2
In reply to this post by Harro Verkouter
Harro Verkouter wrote:
> I suspect this infinite loop whilst compiling for a 64bit target problem
> is mainly g++'s problem, however....

So it seems... I was able to reproduce your issue in a standard x86_64
FC4 install.

     > g++32 --version
     g++32 (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-47.fc4)
     ...

gcc 3.2.3 stalls with your input file, using your command line or just
plain,

     > g++32 -I "${BOOST_ROOT}" infinite_loop.cc

(it is still going ;-)

With gcc-4, however, it's a different story:

     > g++ --version
     g++ (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5)
     ...
     > time g++ -fPIC -g -Wall -W -Werror -fexceptions
         -ftemplate-depth-35 -D_REENTRANT -DBUILDTIME=`date`
         -D_POSIX_PTHREAD_SEMANTICS -m64 -I $"{BOOST_ROOT}"
         -o infinite-loop64 infinite-loop.cc

     real    0m5.105s
     user    0m2.247s
     sys     0m0.248s

Your source compiles cleanly! I think your best option here is to try a
newer version of the compiler or try to push this with gcc.

Best regards,


João


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Re: infinite-loop compilng for 64bit target (32bit works fine)

Harro Verkouter

Hi Joel, João,

Thanks! I'll see if I can push the maintainer of my systems to install a
g++ v4.*

I'm not sure 'bout sending the issue off to gcc - seems like it's
already been fixed... I'll see if I can find where gcc3.* is failing; if
I can point out exactly where it's failing, that might be helpful.

Joel, what I think you were referring to was runtime debugging of Spirit
  (I checked
http://spirit.sourceforge.net/distrib/spirit_1_8_3/libs/spirit/doc/debugging.html 
since I figured that you meant this) but this was not an option since it
was the compiler which got in an infinite loop, not Spirit.

Anyway, thanks again for your time!

Cheers,

Harro Verkouter


João Abecasis wrote:

> Harro Verkouter wrote:
>
>> I suspect this infinite loop whilst compiling for a 64bit target
>> problem is mainly g++'s problem, however....
>
>
> So it seems... I was able to reproduce your issue in a standard x86_64
> FC4 install.
>
>     > g++32 --version
>     g++32 (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-47.fc4)
>     ...
>
> gcc 3.2.3 stalls with your input file, using your command line or just
> plain,
>
>     > g++32 -I "${BOOST_ROOT}" infinite_loop.cc
>
> (it is still going ;-)
>
> With gcc-4, however, it's a different story:
>
>     > g++ --version
>     g++ (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5)
>     ...
>     > time g++ -fPIC -g -Wall -W -Werror -fexceptions
>         -ftemplate-depth-35 -D_REENTRANT -DBUILDTIME=`date`
>         -D_POSIX_PTHREAD_SEMANTICS -m64 -I $"{BOOST_ROOT}"
>         -o infinite-loop64 infinite-loop.cc
>
>     real    0m5.105s
>     user    0m2.247s
>     sys     0m0.248s
>
> Your source compiles cleanly! I think your best option here is to try a
> newer version of the compiler or try to push this with gcc.
>
> Best regards,
>
>
> João
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Spirit-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spirit-general


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general