HaxeFoundation / HaxeFoundation/haxe

ThreadCallbacks discarding exceptions

Open
#12,983 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

I saw this code in ThreadCallbacks:

```haxe
static function iterateCallbacks(callbacks:Array>, f:ThreadCallback -> Void) {
var firstException = null;
for (c in callbacks) {
if (!c.isClosed) {
try {
f(c);
} catch(e:Exception) {
if (firstException == null) {
firstException = e;
}
}
}
}
if (firstException != null) {
throw firstException;
}
}
```

I think it's a very bad idea for several reasons
- it prevents the debugger from breaking at the place you have an exception, you're instead breaking on the `throw firstException`
- it somehow discard all user exceptions happening after the first one, which is really a bad behavior from the user point of view.

In general, the whole "exception during abort or exit which triggers onAbort" is not very well thought through.

Contributor guide

Open the contributing guide

Research direction

Start by locating ThreadCallbacks and its iterateCallbacks method, then inspect the abort and exit paths that invoke onAbort. Reproduce multiple callback exceptions under the debugger and review existing behavior around these paths; done requires an agreed exception-propagation policy and coverage for it.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.