[Box Backup-dev] Reviewing code -- help!

Chris Wilson boxbackup-dev at fluffy.co.uk
Mon Dec 12 03:13:16 GMT 2005


Hi Ben,

>>  I've also had problems with MinGW under emulation (both vmware and 
>>  qemu) where exceptions thrown in one thread cause weird behaviour in 
>>  other threads, leading to deadlocks.
>> 
>>  This is particularly problematic if one uses bbackupctl to start a sync 
>>  while the main thread is blocked in a library call like connect(). I can 
>>  easily and reliably reproduce this.
>
> Is MinGW's exception handler code thread-safe? I've worked with a number of 
> compilers which didn't do this properly. (And when the vendors were 
> contacted, they said "well, we didn't say it had thread-safe exception 
> handling in our feature list").
>
> Sounds like there's a single global structure holding the state of the 
> exception handler stack, and it's being overwritten.

It would appear that this is indeed the problem. I was compiling without 
the -mthreads option, and when an exception was thrown in one thread, it 
would end up jumping to the code of another thread that had an exception 
handler installed, and end up executing that thread's code. So you would 
have two threads trying to run the command socket manager, and none 
running actual backups.

> This is why I have avoided threading in the project so far! Threading 
> and portability is a nightmare. And even on a single platform it's not 
> too fun.

Tell me about it. I've spent three days debugging this :-(

At least it's fixed now: just compile with -mthreads. I've updated the 
MinGW build docs. I also have a test case that I can try to integrate with 
the test framework if you like.
[http://bbdev.fluffy.co.uk/svn/box/chris/win32/crash-test-pipes/bin/bbackupd/BackupDaemon.cpp]

Cheers, Chris.
-- 
_ ___ __     _
  / __/ / ,__(_)_  | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |




More information about the Boxbackup-dev mailing list