9 Feb 2004 12:54
Re: stack trace of the right thread on error
Shiro Kawai <shiro <at> lava.net>
2004-02-09 11:54:51 GMT
2004-02-09 11:54:51 GMT
Hm.
I think the current behavior is straightforward implementation of SRFI-18,
although SRFI-18 isn't very specific about the situation.
When a thread throws an exception and where no user-defined exception
handler is installed, it should call thread's "initial exception handler",
which should terminate the thread. When you call thread-join! on the
thread terminated by such a way, the calling thread gets uncaught-exception.
So, the proper way is to handle the exception in each thread,
probably using with-error-handler. (SRFI-18's with-exception-handler
is very low level in terms of continuation handling; specifically,
you need to use call/cc explicitly if you want to abort the operation
when an exception is raised).
However, it is possible to let the initial exception handler call
report-error before terminating the thread, so that you can see the
stack trace of the thread that raised the error. In such a case,
you'll see two error strack traces (one from the error-causing thread,
another from the thread that calls thread-join!) unless you handles
thread's error by yourself.
Try the following patch and let me know how you like.
--shiro
===================================================================
RCS file: /cvsroot/gauche/Gauche/ext/threads/threads.c,v
retrieving revision 1.5
diff -c -r1.5 threads.c
*** threads.c 5 Jul 2003 03:29:11 -0000 1.5
--- threads.c 9 Feb 2004 11:50:30 -0000
***************
*** 135,140 ****
--- 135,141 ----
exc = Scm_MakeThreadException(SCM_CLASS_UNCAUGHT_EXCEPTION, vm);
SCM_THREAD_EXCEPTION(exc)->data = SCM_OBJ(vm->escapeData[1]);
vm->resultException = exc;
+ Scm_ReportError(SCM_OBJ(vm->escapeData[1]));
break;
}
} SCM_END_PROTECT;
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
RSS Feed