Skip to content

Commit

Permalink
Use __builtin_trap to crash intentionally
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Mar 14, 2024
1 parent 0ce0085 commit e9dc676
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Inweb 7.2.1

[Version](notes/versioning.md): 7.2.1-beta+1B59 'Escape to Danger' (26 January 2024)
[Version](notes/versioning.md): 7.2.1-beta+1B60 'Escape to Danger' (14 March 2024)

## About Inweb

Expand Down
4 changes: 2 additions & 2 deletions build.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Prerelease: beta
Build Date: 26 January 2024
Build Number: 1B59
Build Date: 14 March 2024
Build Number: 1B60
3 changes: 1 addition & 2 deletions docs/foundation-module/3-em.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ <h1><a href="../index.html">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DL</span><span class="plain-syntax">) </span><span class="identifier-syntax">STREAM_FLUSH</span><span class="plain-syntax">(</span><span class="identifier-syntax">DL</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">debugger_mode</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"(crashing intentionally to allow backtrace)\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">to_deliberately_crash</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">printf</span><span class="plain-syntax">(</span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">/</span><span class="identifier-syntax">to_deliberately_crash</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">__builtin_trap</span><span class="plain-syntax">(); </span><span class="comment-syntax"> both a gcc and clang extension to C, so fairly standard</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="comment-syntax"> on a fatal exit, memory isn't freed, because that causes threading problems</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">exit</span><span class="plain-syntax">(2);</span>
Expand Down
4 changes: 3 additions & 1 deletion docs/foundation-module/5-htm.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,10 @@ <h1><a href="../index.html">

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">HTML::incorporate_CSS_from_file</span><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">M</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="5-htm.html#SP11" class="function-link"><span class="function-syntax">HTML::open_CSS</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-tf.html#SP5" class="function-link"><span class="function-syntax">TextFiles::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">M</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><a href="5-htm.html#SP12" class="function-link"><span class="function-syntax">HTML::incorporate_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUT</span><span class="plain-syntax">) == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-tf.html#SP5" class="function-link"><span class="function-syntax">TextFiles::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">M</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><a href="5-htm.html#SP12" class="function-link"><span class="function-syntax">HTML::incorporate_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUT</span><span class="plain-syntax">) == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"CSS filename: %f\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">M</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"Unable to open model CSS material for reading"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="5-htm.html#SP11" class="function-link"><span class="function-syntax">HTML::close_CSS</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

Expand Down
Binary file modified docs/goldbach/goldbach.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions foundation-module/Chapter 3/Error Messages.w
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ void Errors::die(void) { /* as void as it gets */
if (DL) STREAM_FLUSH(DL);
if (debugger_mode) {
WRITE_TO(STDERR, "(crashing intentionally to allow backtrace)\n");
int to_deliberately_crash = 0;
printf("%d", 1/to_deliberately_crash);
__builtin_trap(); /* both a gcc and clang extension to C, so fairly standard */
}
/* on a fatal exit, memory isn't freed, because that causes threading problems */
exit(2);
Expand Down
4 changes: 3 additions & 1 deletion foundation-module/Chapter 5/HTML.w
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ void HTML::incorporate_CSS(OUTPUT_STREAM, filename *M) {

void HTML::incorporate_CSS_from_file(OUTPUT_STREAM, filename *M) {
HTML::open_CSS(OUT);
if (TextFiles::read(M, FALSE, NULL, FALSE, HTML::incorporate_helper, NULL, OUT) == FALSE)
if (TextFiles::read(M, FALSE, NULL, FALSE, HTML::incorporate_helper, NULL, OUT) == FALSE) {
WRITE_TO(STDERR, "CSS filename: %f\n", M);
internal_error("Unable to open model CSS material for reading");
}
HTML::close_CSS(OUT);
}

Expand Down

0 comments on commit e9dc676

Please sign in to comment.