[sword-devel] thread-safety in libsword?

Teus Benschop teusjannette at gmail.com
Tue Jan 12 07:35:56 MST 2016


Hi Troy,

The libsword code is being accessed by multiple threads in Bibledit.
In the demo at http://bibledit.org:8080/resource/index, then displaying
multiple SWORD resources in parallel, each resource creates one thread on
the sever, and that thread returns rendered text from libsword.
The code that Костя Маслюк mentions in the bug report hits the same issue.
I think the small code that is included in that bug report captures the
issues.
The standalone program I can produce is not "small", but it is not awfully
big either.
To get this, the easiest and quickest is to install Bibledit Cloud, as
described here: http://bibledit.org:8080/help/installcloudubuntu.
Then to display multiple parallel SWORD resources.
File "sword/logic.cpp" (
https://github.com/teusbenschop/bibledit/blob/master/lib/sword/logic.cpp)
as it is now handles thread safety.
To get the crashes, remove sword_logic_library_access_mutex.lock ();
and sword_logic_library_access_mutex.unlock (); from that file, compile
again, and then load 20++ SWORD resources in menu "Translate" / "View
resources", via the "organize" link, and crashes are guaranteed to occur.
I personally am happy to include the mutexes manually. That's good enough
for me.

Thanks for creating a great library!

Teus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20160112/a798f1e7/attachment-0001.html>


More information about the sword-devel mailing list