silent breakage without -pthread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just spent a bunch of time debugging some multi-threaded code that
used to work, but had started failing in odd ways.

It turned out the problem was that I wasn't using the gcc -pthread
option; it had worked previously because a random library's pkg-config
generated included -pthread, but I had changed the library mix to omit
that library.

The threading interface I was using was std::thread.  Without -pthread,
threads kinda-sorta worked, but e.g. mutexes were nops!

Now, the requirement for -pthread is well-known, and maybe requiring the
option is the practical thigng to do (I dunno), but now that gcc
includes its own standard threading facility, I wonder if it might be a
good idea if things at least failed more obviously when -pthread was
inadvertently omitted...

[I _already knew_ about the requirement for -pthread, and I imagine the
debugging experience would have been even more miserable for someone
who's just starting to use threads... Even looking at a disassembly of
my functions, there were appropriate calls to the mutex lock/unlock
functions...that just didn't do anything.]

Ideas?

Thanks,

-miles


-- 
Electricity, n. The cause of all natural phenomena not known to be caused by
something else.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux