digitalmars.D - Should core.stdc.signal.signal be nothrow nogc??
Hello All I am trying to make use of function signal from module core.stdc.signal. The function needs a function pointer as an argument and since signal has been marked with attributes nogc and nothrow, the function I pass to it as an argument also has to be nothrow and nogc. Are these attributes intended on signal? If yes, how does it help. Why should C functions in core.stdc be marked nothrow and nogc? And how do I overcome the restriction imposed on function pointer that I want to pass to signal? In my case the function I want to pass as argument to signal is actually not nogc nothrow. What should I do? Regards - Genie
May 15 2016
To be specific, I am trying to get an automatic backtrace generated for my d application in case of segfaults, using the technique shown in the following link: http://stackoverflow.com/a/77336 Going by the code snippet in the link I have to pass a pointer to function handler as an argument to signal. And signal having being declared as nogc nothrow expects handler to have the same attributes. But handler calls backtrace and backtrace_symbols_fd which are declared in module core.sys.linux.execinfo and do not have nogc attribute, thus making it impossible for me to specify nogc with the handler function. I believe the solution lies in adding nogc for all the functions in execinfo module. Am I missing something? Regards - Genie
May 16 2016
Can someone help me? How can I call core.sys.linux.execinfo:backtrace from a core.stdc.signal: signal handler? The problem is that signal has been declared with nogc in druntime and backtrace does not have that attribute.
May 17 2016
Joakim <dlang joakim.fea.st> writes:
On Tuesday, 17 May 2016 at 09:24:50 UTC, Bottled Genie wrote:Can someone help me? How can I call core.sys.linux.execinfo:backtrace from a core.stdc.signal: signal handler? The problem is that signal has been declared with nogc in druntime and backtrace does not have that attribute.There is a problem in druntime with nogc and nothrow not covering all the C declarations they should. If you're comfortable with writing up a PR to fix this issue, it'll most likely be merged: http://wiki.dlang.org/Starting_as_a_Contributor
May 17 2016