[thread] [trunk] mutex: Invalid argument

Hi Everyone, This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes. The platform I'm working on is: Intel Core 2 Quad CPU @ 2.40 Ghz Ubuntu Gutsy Gibbon 7.10 Linux Kernel 2.6.22-14-server (x86_64) gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2) I'm working off of Boost's SVN trunk revision 43586. The system is running in 64-bit mode (which may or may not say what the problem can be, because I don't see this problem in 32-bit systems as well as other 64-bit systems). Pointers would be greatly appreciated. -- Dean Michael Berris Software Engineer, Friendster, Inc. <dmberris@friendster.com> +639287291459

Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
The platform I'm working on is:
Intel Core 2 Quad CPU @ 2.40 Ghz Ubuntu Gutsy Gibbon 7.10 Linux Kernel 2.6.22-14-server (x86_64) gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
That's very similar to my linux development system --- I've got a core2duo running Ubuntu 7.10 with a 2.6.22-16 kernel in 64-bit mode, and everything works for me. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Hi Anthony, On Thu, Mar 13, 2008 at 6:04 PM, Anthony Williams <anthony_w.geo@yahoo.com> wrote:
Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
You can browse the source for the Memcache++ Client here: http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/memcache%2B%2B... (or http://tinyurl.com/3yr7ju) -- It may just be the machine I'm running on has a defect of some sort (memory corruption?) or some hardware problem(s). That said, that's the last thing I would be able to look into at the moment.
The platform I'm working on is:
Intel Core 2 Quad CPU @ 2.40 Ghz Ubuntu Gutsy Gibbon 7.10 Linux Kernel 2.6.22-14-server (x86_64) gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
That's very similar to my linux development system --- I've got a core2duo running Ubuntu 7.10 with a 2.6.22-16 kernel in 64-bit mode, and everything works for me.
Hmmm... That's odd. I'm pasting the cpuinfo for the system here -- maybe something there will help. And btw, there are 4 processors in the system like this. There's also 4 GB of RAM available. processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 model name : Intel(R) Core(TM)2 Quad CPU @ 2.40GHz stepping : 7 cpu MHz : 2400.123 cache size : 4096 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm bogomips : 4802.87 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: I hope this helps. -- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://blog.cplusplus-soup.com] [mikhailberis@gmail.com] [+63 928 7291459] [+1 408 4049523]

Dean Michael Berris <dmberris <at> friendster.com> writes:
On Thu, Mar 13, 2008 at 6:04 PM, Anthony Williams <anthony_w.geo <at> yahoo.com> wrote:
Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
You can browse the source for the Memcache++ Client here: http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/memcache%2B%2B...
Thanks. Is the test code available online too? Where does the "mutex: Invalid argument" message come from? This isn't a message from boost.threads. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Anthony Williams wrote:
Dean Michael Berris <dmberris <at> friendster.com> writes:
On Thu, Mar 13, 2008 at 6:04 PM, Anthony Williams <anthony_w.geo <at> yahoo.com> wrote:
Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
You can browse the source for the Memcache++ Client here: http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/memcache%2B%2B...
Thanks. Is the test code available online too? Where does the "mutex: Invalid argument" message come from? This isn't a message from boost.threads.
It looks to me like errno==EINVAL being converted to a string. Maybe strace would help? Phil.

Hi Anthony, On Thu, Mar 13, 2008 at 9:22 PM, Anthony Williams <anthony_w.geo@yahoo.com> wrote:
Dean Michael Berris <dmberris <at> friendster.com> writes:
On Thu, Mar 13, 2008 at 6:04 PM, Anthony Williams <anthony_w.geo <at> yahoo.com> wrote:
Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
You can browse the source for the Memcache++ Client here: http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/memcache%2B%2B...
Thanks. Is the test code available online too? Where does the "mutex: Invalid argument" message come from? This isn't a message from boost.threads.
http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/test/memcache_... is the test which throws on destroying memcache handles, and related to locking mutexes. This also uses ASIO underneath, and I'm not sure if it may be ASIO related. For one thing, it throws a boost::system::system_error which encapsulates the 'mutex: Invalid argument' in the 'what()' method. I checked Boost.Thread and it throws system errors like ASIO does -- so right now I'm limiting it to just Boost.Thread because it seems to be the more logical place from which mutex errors would come from. Thanks for looking into this, and I hope this helps. -- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://blog.cplusplus-soup.com] [mikhailberis@gmail.com] [+63 928 7291459] [+1 408 4049523]

Hi Dean, Dean Michael Berris <mikhailberis <at> gmail.com> writes:
On Thu, Mar 13, 2008 at 9:22 PM, Anthony Williams <anthony_w.geo <at> yahoo.com> wrote:
Dean Michael Berris <dmberris <at> friendster.com> writes:
On Thu, Mar 13, 2008 at 6:04 PM, Anthony Williams <anthony_w.geo <at> yahoo.com> wrote:
Dean Michael C. Berris <dmberris <at> friendster.com> writes:
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
What does your code look like?
You can browse the source for the Memcache++ Client here: http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/memcache%2B%2B...
Thanks. Is the test code available online too? Where does the "mutex: Invalid argument" message come from? This isn't a message from boost.threads.
http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/test/memcache_...
is the test which throws on destroying memcache handles, and related to locking mutexes.
Thanks. I'll try it on my linux box later.
This also uses ASIO underneath, and I'm not sure if it may be ASIO related. For one thing, it throws a boost::system::system_error which encapsulates the 'mutex: Invalid argument' in the 'what()' method. I checked Boost.Thread and it throws system errors like ASIO does -- so right now I'm limiting it to just Boost.Thread because it seems to be the more logical place from which mutex errors would come from.
Boost.Thread doesn't throw system_error anywhere. Most throws are thread_resource_error, and some are lock_error, but none are system_error. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Hi Anthony! On Fri, Mar 14, 2008 at 4:00 PM, Anthony Williams <anthony_w.geo@yahoo.com> wrote:
Hi Dean,
Dean Michael Berris <mikhailberis <at> gmail.com> writes:
http://memcachepp.svn.sourceforge.net/viewvc/memcachepp/trunk/test/memcache_...
is the test which throws on destroying memcache handles, and related to locking mutexes.
Thanks. I'll try it on my linux box later.
This will not come as a surprise, but I think I've found the cause -- and the solution.
This also uses ASIO underneath, and I'm not sure if it may be ASIO related. For one thing, it throws a boost::system::system_error which encapsulates the 'mutex: Invalid argument' in the 'what()' method. I checked Boost.Thread and it throws system errors like ASIO does -- so right now I'm limiting it to just Boost.Thread because it seems to be the more logical place from which mutex errors would come from.
Boost.Thread doesn't throw system_error anywhere. Most throws are thread_resource_error, and some are lock_error, but none are system_error.
It does seem like ASIO is involved somehow. The problem lies in the destruction of ASIO sockets expecially once the io_service it's tied to is already deleted. This may better be called as a 'dangling reference' problem, which is caused by my relying on the destructor of the containers in the memcache handle to do the right thing in the right order. All I had to do is add appropriate clearing of the containers in the handle at the destructor to make sure that the elements of the containers are deleted before the io_service is stopped (and later deleted). This evidently fixed the problem in the platform I'm using, and a subtle bug that doesn't appear in other platforms (yet). Charge this as PEBKAC instead of an actual bug. ;-) Have a good day everyone, and sorry for the noise. -- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://blog.cplusplus-soup.com] [mikhailberis@gmail.com] [+63 928 7291459] [+1 408 4049523]

Dean Michael Berris <mikhailberis <at> gmail.com> writes:
Have a good day everyone, and sorry for the noise.
No problem. I'm glad you found the cause of your bug. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Dean Michael C. Berris wrote:
Hi Everyone,
This has been bothering me a while -- as I'm working on the Memcache++ Client that I'm maintaining and continuing to develop, when I try running the unit test(s) I've written in a specific platform I get 'mutex: Invalid argument' errors being thrown with regards to either locking, unlocking, or destroying mutexes.
Just to chime in here. I've seen this also recently while working off trunk. I cannot remember the context right now but I'll see if I can do so later on. I'm on a dell d830 with core2 duo. Basically I just wanted to flag that this is not an isolated observation limited to just your machine. Apologies for not being more specific at this time. Jamie
participants (6)
-
Anthony Williams
-
Dean Michael Berris
-
Dean Michael Berris
-
Dean Michael C. Berris
-
Jamie Allsop
-
Phil Endecott