1 // Make sure we can throw exceptions from work items executed via
2 // BindIoCompletionCallback.
4 // RUN: %clangxx_asan %s -o %t.exe
5 // RUN: %run %t.exe 2>&1 | FileCheck %s
14 fprintf(stderr
, "Throw\n");
19 void ThrowAndCatch() {
24 fprintf(stderr
, "Catch\n");
33 void CALLBACK
completion_callback(DWORD error
, DWORD bytesRead
,
39 int main(int argc
, char **argv
) {
40 done
= CreateEvent(0, false, false, "job is done");
43 HANDLE file
= CreateFile(
44 argv
[0], GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
,
46 FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_NO_BUFFERING
| FILE_FLAG_OVERLAPPED
,
50 if (!BindIoCompletionCallback(file
, completion_callback
, 0))
53 if (!ReadFile(file
, buffer
, sizeof(buffer
), NULL
, &ov
) &&
54 GetLastError() != ERROR_IO_PENDING
)
57 if (WAIT_OBJECT_0
!= WaitForSingleObject(done
, 10 * 1000))
59 fprintf(stderr
, "Done!\n");