Opened 11 years ago

Closed 10 years ago

#5542 closed Bugs (worksforme)

Segmentation fold in boost/thread.hpp Linux -x86_64

Reported by: One People <leonardo777@…> Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.46.1 Severity: Problem
Keywords: thread segmentation fold Cc: g++ 4.5

Description

Every time Im trying to create new thread, I receve an Segmentation Fold. Even in the simplest examples founded in internet. Debugger in NetBeans has shown me, that this problem happends, while Im trying to do start_thread() - method from thread class included in boost/thread.hpp - file.

Computer specification:

  • procesor i7 720QM (I`ve seen some asm code)
  • linux mint 10 - Julia
  • kernel version 2.6.38.2

Compilation command: g++-4.5 -pthread -lboost_thread t1.cpp -o t1

Example code used:

#include <iostream>
#include <boost/thread.hpp>

class Worker
{
public:

    Worker()
    {
        // the thread is not-a-thread until we call start()
    }

    void start(int N)
    {
      std::cout << "start\n";
        m_Thread = boost::thread(&Worker::processQueue, this, N);
        std::cout << "started\n";
    }

    void join()
    {
        m_Thread.join();
    }

    void processQueue(unsigned N)
    {
        float ms = N * 1e3;
        boost::posix_time::milliseconds workTime(ms);

        std::cout << "Worker: started, will work for "
                  << ms << "ms"
                  << std::endl;

        // We're busy, honest!
        boost::this_thread::sleep(workTime);

        std::cout << "Worker: completed" << std::endl;
    }

private:

    boost::thread m_Thread;
};

int main(int argc, char* argv[])
{
    std::cout << "main: startup" << std::endl;

    Worker worker;

    std::cout << "main: create worker" << std::endl;

    worker.start(3);

    std::cout << "main: waiting for thread" << std::endl;

    worker.join();

    std::cout << "main: done" << std::endl;

    return 0;
}

More included as files.

Attachments (2)

t1.cpp (606 bytes ) - added by One People <leonardo777@…> 11 years ago.
Another used example code
t5.cpp (1013 bytes ) - added by One People <leonardo777@…> 11 years ago.

Download all attachments as: .zip

Change History (7)

by One People <leonardo777@…>, 11 years ago

Attachment: t1.cpp added

Another used example code

by One People <leonardo777@…>, 11 years ago

Attachment: t5.cpp added

comment:1 by leonardo777@…, 11 years ago

Summary: Segmentation fold in boost/thread.hppSegmentation fold in boost/thread.hpp Linux -x86_64

comment:2 by Branan Purvine-Riley <branan@…>, 11 years ago

I'm having the same issue, and can confirm that this occurs even with the most trivial boost::thread program.

#include <boost/thread.hpp>

void run_thread() {
        return;
}

int main() {
        boost::thread t(run_thread);
        return 0;
}

And the backtrace (built in release mode with debug symbols, so I'm not sure how useful it is):

#0  operator= (this=0x7fffffffd670) at ./boost/smart_ptr/shared_ptr.hpp:305
#1  boost::thread::start_thread (this=0x7fffffffd670) at libs/thread/src/pthread/thread.cpp:185
#2  0x00000000004025e2 in boost::thread::thread<void (*)()>(void (*)(), boost::disable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type) ()
#3  0x000000000040182a in main ()

Boost version is 1.6.1, built with gcc (Gentoo 4.4.5 p1.2, pie-0.4.5) 4.4.5

comment:3 by Branan Purvine-Riley <branan@…>, 11 years ago

Whoops, that should be "Boost version 1.46.1", not 1.6.1 >_<

comment:4 by viboes, 11 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

When I compile the attached examples (the 3) with bjam on the trunk everything is OK. Could you tell me if you are able to reproduce using the trunk?

Last edited 10 years ago by viboes (previous) (diff)

comment:5 by viboes, 10 years ago

Resolution: worksforme
Status: assignedclosed

Closed as no answer.

Note: See TracTickets for help on using tickets.