Skip to content

Commit

Permalink
Hints for common submission errors (#334)
Browse files Browse the repository at this point in the history
* Hints for common submission errors

* Use <ul> for error hints

* FA icons instead of inline svg
  • Loading branch information
metenn authored Mar 13, 2024
1 parent 9d5ef68 commit 34a13a5
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 1 deletion.
8 changes: 7 additions & 1 deletion oioioi/contests/templates/contests/submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@
{{ header }}
<div class="row">
{% for report in reports %}
<div class="{% if submission.status != 'CE' and submission.status != 'SE' %}col-xl-6{% endif %}">
<div class="{% if submission.status != 'CE' and submission.status != 'SE' %}col-xl-6{% endif %}">
{{ report }}
<div class="alert alert-info">
{% if submission.status == 'SE' %}
<i class="fa-solid fa-circle-info"></i>
{% trans "Something went wrong on our side when judging your submission... Try again later or contact the administration if this issue persists." %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
Expand Down
13 changes: 13 additions & 0 deletions oioioi/programs/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ def render_report(self, request, report):
all_outs_generated = allow_download_out

groups = []
signals_to_explain = set()
# Sioworkers doesn't give us exit codes or signals explicitly. Neither does sio2jail.
# This detection mechanism is similar to the one sioworkers uses to give a RE verdict:
# https://github.com/sio2project/sioworkers/blob/55776ac98613ff2b11bd63397be536029616b9bb/sio/workers/executors.py#L670
signal_exit_msg = 'process exited due to signal '
for group_name, tests in itertools.groupby(
test_reports, attrgetter('test_group')
):
Expand All @@ -740,6 +745,13 @@ def render_report(self, request, report):
for test in tests_list:
test.generate_status = picontroller._out_generate_status(request, test)
all_outs_generated &= test.generate_status == 'OK'
# Extract all error signals from the test report according to the format
if test.comment.startswith(signal_exit_msg):
try:
signal = int(test.comment[len(signal_exit_msg):])
signals_to_explain.add(signal)
except ValueError:
pass

tests_records = [
{'display_type': get_report_display_type(request, test), 'test': test}
Expand All @@ -761,6 +773,7 @@ def render_report(self, request, report):
'allow_test_comments': allow_test_comments,
'all_outs_generated': all_outs_generated,
'is_admin': picontroller.is_admin(request, report),
'signals_to_explain': signals_to_explain,
},
)

Expand Down
3 changes: 3 additions & 0 deletions oioioi/programs/templates/programs/report-comments.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{% load i18n %}
{% load runtimeformat %}

{% if allow_test_comments and signals_to_explain %}
{% include "programs/report-signal-hint.html" %}
{% endif %}
<ul class="list-unstyled">
{% for group in groups %}
{% for record in group.tests %}
Expand Down
73 changes: 73 additions & 0 deletions oioioi/programs/templates/programs/report-signal-hint.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% load i18n %}

<div class="alert alert-info">
<i class="fa-solid fa-circle-info"></i>
<br>
{% for signal in signals_to_explain %}
{% if signal == 6 %}
{% blocktrans %}
<b>Most common causes of the SIGABRT signal (signal 6):</b>
<ul>
<li>Out-of-bounds index access for the vector data structure</li>
<li>Array allocation with an invalid size e.g. <code>int tab[-1];</code></li>
<li>Bad use of C++ standard library functions, e.g. <code>sort()</code> over an invalid range</li>
<li>A failed assertion when using <code>assert</code> - commonly used by the C++ Standard Library</li>
<li>Other illegal memory operations.</li>
</ul>
{% endblocktrans %}
{% elif signal == 7 %}
{% blocktrans %}
<b>The SIGBUS signal (signal 7)</b> can mean a general memory violation, and can
be caused by trying to access an invalid memory address.
{% endblocktrans %}
<br>
{% elif signal == 8 %}
{% blocktrans %}
<b>Most common causes of the SIGFPE signal (signal 8):</b>
<ul>
<li>Overflows/underflows for floating-point numbers</li>
<li>Division by zero, either with floating-point numbers and integers</li>
<li>Other illegal arithmetic operations, e.g. square-root of negative numbers.</li>
</ul>
{% endblocktrans %}
{% elif signal == 9 %}
{% blocktrans %}
<b>Most common sources for the SIGKILL signal (signal 9):</b>
<ul>
<li>Your global variable exceeds the memory limit
<br>(The difference compared to MLE is that the program exits before it can even "fully start")
</li>
<li>Other unexpected operations causing the program to get terminated preemptively.</li>
</ul>
{% endblocktrans %}
{% elif signal == 11 %}
{% blocktrans %}
<b>Most common causes of the SIGSEGV signal (signal 11):</b>
<ul>
<li>Out-of-bounds array accesses</li>
<li>De-referencing an invalid pointer (an empty "null-pointer" or a pointer to memory which has already been freed)</li>
<li>Other memory violation errors</li>
</ul>
{% endblocktrans %}
{% elif signal == 31 %}
{% blocktrans %}
<b>Most common causes of the SIGSYS signal (signal 31):</b>
<ul>
<li>Using a system call (syscall) that's not allowed by this task/contest.</li>
<li>Using an invalid/non-existent system call.</li>
</ul>
{% endblocktrans %}
{% else %}
<span style="color: red;font-size: 1.5rem;font-weight: bold">
{% blocktranslate with signal=signal %}
Signal {{ signal }} shouldn't show up while checking...
<u>We recommend reporting this issue.</u>
{% endblocktranslate %}
</span>
{% endif %}
{% endfor %}
<hr>
{% blocktranslate %}
Program execution can differ depending on the operating system used and the execution environment.
{% endblocktranslate %}
</div>
8 changes: 8 additions & 0 deletions oioioi/programs/templates/programs/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ <h4>{% trans "Report:" %} {{ report.kind }}</h4>
<pre>
{{ compilation_report.compiler_output }}
</pre>
{% if 'relocation truncated to fit' in compilation_report.compiler_output %}
<div class="alert alert-info">
<i class="fa-solid fa-circle-info"></i>
{% blocktrans %}
This compilation error most commonly occurs when your global variable(s) are too large.
{% endblocktrans %}
</div>
{% endif %}
{% else %}
{% include "programs/report-body.html" %}
{% include "programs/report-comments.html" with groups=groups %}
Expand Down

0 comments on commit 34a13a5

Please sign in to comment.