Shared library: loading doesn't call shared static this
Mathias LANG
pro.mathias.lang at gmail.com
Sat Dec 7 12:11:14 PST 2013
Hello,
I'm in the process of creating a PAM module using D.
First step, I ported <pam/modules.h> and the included
pam/_types.h> to D, pretty straightforward.
Then I created a simple D source, which looks like:
````
extern(C) int pam_sm_open_session(pam_handle_t* pamh, int flags,
int ac, const char** av)
{
writeln(__PRETTY_FUNCTION__);
return PAM_SUCCESS;
}
````
Compiled it using dub, set up PAM & all the required stuff (I've
already wrote one in C so it was pretty easy), and ran my test
util, written in C.
I got a SIGSEGV.
I tracked it down to be the writeln call, it seems the fd are not
initialized.
Easy way to fix it is to call std_stdio_static_this() from
std.stdiobase.
So I went to http://dlang.org/dll-linux.html , copied the
example, and here's my result:
xxxx at xxxx:~/Work/PAM$ ./main
+main()
Dynamic library is loaded
dll() function is found
dll()
unloading libdll.so
-main()
Which differs from the example in that the "shared static this"
are not called.
Is that a bug ?
NB: DMD 2.064.2, debian x86_64, gcc 4.8.2
More information about the Digitalmars-d-learn
mailing list