Debugging D shared libraries
Russel Winder via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 19 03:45:02 PDT 2015
Calling D from Python. I have two functions in D, compiled to a shared
object on Linux using LDC (but I get same problem using DMD).
The sequential code:
extern(C)
double sequential(const int n, const double delta) {
Runtime.initialize();
const pi = 4.0 * delta * reduce!(
(double t, int i){ immutable x = (i - 0.5) * delta; return t + 1.0 / (1.0 + x * x); })(
0.0, iota(1, n + 1));
Runtime.terminate();
return pi;
}
works entirely fine. However the "parallel" code:
extern(C)
double parallel(const int n, const double delta) {
Runtime.initialize();
const pi = 4.0 * delta * taskPool.reduce!"a + b"(
map!((int i){ immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x * x); })(iota(1, n + 1)));
Runtime.terminate();
return pi;
}
causes an immediate segfault (with LDC and DMD. I am assuming that the
problem is the lack of initialization of the std.parallelism module and
hence the use of taskPool is causing a problem. I am betting I am
missing something very simple about module initialization, and that
this is not actually a bug.
Anyone any proposals?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150919/f43b458c/attachment.sig>
More information about the Digitalmars-d-learn
mailing list