Merge pull request #3899 from urbit/jb/bail-sane

u3: refactors fatal exception handling in u3m_bail()
This commit is contained in:
Joe Bryan 2020-11-05 23:55:25 -08:00 committed by GitHub
commit a111c93804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,8 +600,6 @@ u3m_dump(void)
} }
#endif #endif
c3_w Exit;
/* u3m_bail(): bail out. Does not return. /* u3m_bail(): bail out. Does not return.
** **
** Bail motes: ** Bail motes:
@ -612,7 +610,6 @@ c3_w Exit;
** %intr :: interrupt ** %intr :: interrupt
** %fail :: computability failure ** %fail :: computability failure
** %over :: stack overflow (a kind of %fail) ** %over :: stack overflow (a kind of %fail)
** %need :: namespace block
** %meme :: out of memory ** %meme :: out of memory
** **
** These are equivalents of the full exception noun, the error ball: ** These are equivalents of the full exception noun, the error ball:
@ -651,30 +648,15 @@ u3m_bail(u3_noun how)
} }
} }
// intercept fatal errors
//
switch ( how ) { switch ( how ) {
case c3__fail: { case c3__foul:
break; case c3__meme:
} case c3__oops: {
case c3__meme: {
fprintf(stderr, "bailing out\r\n"); fprintf(stderr, "bailing out\r\n");
abort(); abort();
} }
case c3__exit: {
static c3_w xuc_w = 0;
{
// u3l_log("exit %d\r\n", xuc_w);
// if ( 49 == xuc_w ) { abort(); }
xuc_w++;
break;
}
}
case c3__foul:
case c3__oops:
fprintf(stderr, "bailing out\r\n");
assert(0);
} }
if ( &(u3H->rod_u) == u3R ) { if ( &(u3H->rod_u) == u3R ) {
@ -688,21 +670,15 @@ u3m_bail(u3_noun how)
/* Reconstruct a correct error ball. /* Reconstruct a correct error ball.
*/ */
{ if ( _(u3ud(how)) ) {
if ( _(u3ud(how)) ) { switch ( how ) {
switch ( how ) { case c3__exit: {
case c3__exit: { how = u3nc(2, u3R->bug.tax);
how = u3nc(2, u3R->bug.tax); } break;
break;
} default: {
case c3__need: { how = u3nt(3, how, u3R->bug.tax);
c3_assert(0); } break;
}
default: {
how = u3nt(3, how, u3R->bug.tax);
break;
}
}
} }
} }