mark core.sys.posix.pthread as nothrow #232

Merged
merged 1 commit into from Jun 20, 2012
Jump to file or symbol
Failed to load files and symbols.
+2 −2
Split
@@ -21,7 +21,7 @@ public import core.sys.posix.time;
import core.stdc.stdint;
-extern (C):
+extern (C) nothrow:
@jmdavis

jmdavis Jun 7, 2012

Member

I'm not sure that this is actually a valid thing to do, since it affects everything in the file, including functions which take function pointers, and if those functions throw, then the function they're passed to isn't really nothrow.

Most of what's in the file can be safely marked nothrow, but I question that all of it can be.

@MartinNowak

MartinNowak Jun 7, 2012

Member

Yeah, I'm aware of this but I'm not yet sure if we need some kind of deprecation here.
Probably it's better to annotate the whole core.sys package at once.

Anyhow it's undeniably a bug to let a C library call back into throwing functions.
Luckily we already have that correct for atexit et.al..

@alexrp

alexrp Jun 20, 2012

Member

Actually, I'm not so sure. In my usage of libffi in a VM interpreter, I found that unwinding through C frames by throwing D exceptions works perfectly fine.

But maybe I'm misunderstanding?

@MartinNowak

MartinNowak Jun 20, 2012

Member

works perfectly fine

s/perfectly fine/by chance/
Really the runtime relies on proper EBP frames and things easily break apart.
JakobOvrum/LuaD#35
JakobOvrum/LuaD#40

In this particular case (pthread_cleanup_push) being able to reliably unwind the stack doesn't help either because the caller is unaware of exceptions. At least we're aborting now in such cases (f5c58c2).

@alexrp

alexrp Jun 20, 2012

Member

Fair enough. Then I don't think there's anything keeping this from being merged?

//
// Required
View
@@ -386,7 +386,7 @@ else version( Posix )
Thread.add( &obj.m_main );
obj.m_tlsgcdata = rt.tlsgc.init();
- static extern (C) void thread_cleanupHandler( void* arg )
+ static extern (C) void thread_cleanupHandler( void* arg ) nothrow
{
Thread obj = cast(Thread) arg;
assert( obj );