> On Jun 27, 2018, at 12:36 PM, Daniel Roßberg <danielmrossb...@gmail.com> 
> wrote:
> 
> Is the Tk-mged supposed to work with multiple threads?  It looks like if a 
> simple call to bu_log() in a subthread can crash it.

It is supposed to work, but that’s been historically tricky code to get right 
and keep working because of how libbu manages a set of global locks.  
Currently, nearly everything goes through BU_SEM_SYSCALL which means you can’t 
recursively call bu functions from bu functions safely without hitting a 
deadlock, race, or other issue.  This is particularly problematic for bu_log() 
and it’s hook functions (which very often are written to call bu functions, but 
that’s nfg) and bu_malloc() and friends.

What’s needed is breaking up BU_SEM_SYSCALL into different semaphores for each 
of the respective bu groupings that need to coordinate some access.

> Archer behaves different.  It doesn't crash, the bu_log() messages go however 
> to the console.

Where log messages go is archer’s context is both a function of the registered 
bu_log() callback as well as what fd 1 and 2 are set to.  I believe there is 
currently and ifdef block that doesn’t redirect output in some cases which 
causes it to send output to console.  All subject to change.  There’s no 
requirement or expectation that it’s right behavior — just needs a motivated 
dev to make it better. ;)

Cheers!
Sean

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to