Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Fix 20778 - Ensure that _d_print_throwable prints the entire message #3787

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rt/dmain2.d
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ extern (C) void _d_print_throwable(Throwable t)

void sink(in char[] buf) scope nothrow
{
fprintf(stderr, "%.*s", cast(int)buf.length, buf.ptr);
fwrite(buf.ptr, char.sizeof, buf.length, stderr);
}
formatThrowable(t, &sink);
}
22 changes: 17 additions & 5 deletions test/exceptions/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include ../common.mak

TESTS=stderr_msg unittest_assert invalid_memory_operation unknown_gc static_dtor \
future_message refcounted rt_trap_exceptions_drt catch_in_finally
future_message refcounted rt_trap_exceptions_drt catch_in_finally \
message_with_null

ifeq ($(OS)-$(BUILD),linux-debug)
TESTS+=line_trace line_trace_21656 long_backtrace_trunc rt_trap_exceptions
Expand Down Expand Up @@ -77,13 +78,24 @@ $(ROOT)/catch_in_finally.done: STDERR_EXP="success."
$(ROOT)/rt_trap_exceptions.done: STDERR_EXP="object.Exception@src/rt_trap_exceptions.d(12): this will abort"
$(ROOT)/rt_trap_exceptions.done: STDERR_EXP2="src/rt_trap_exceptions.d:8 main"
$(ROOT)/assert_fail.done: STDERR_EXP="success."

$(ROOT)/message_with_null.done: STDERR_EXP=" world"

$(ROOT)/%.done: $(ROOT)/%
@echo Testing $*
$(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>$(ROOT)/$*.stderr || true
cat $(ROOT)/$*.stderr
$(NEGATE) grep -qF $(STDERR_EXP) < $(ROOT)/$*.stderr
if [ ! -z $(STDERR_EXP2) ] ; then \
$(NEGATE) grep -qF $(STDERR_EXP2) < $(ROOT)/$*.stderr; \

@if $(NEGATE) grep -qF $(STDERR_EXP) < $(ROOT)/$*.stderr ; then true ; else \
echo 'Searched for pattern $(STDERR_EXP), NEGATE = $(NEGATE)' ;\
tail --bytes=5000 $(ROOT)/$*.stderr ;\
exit 1 ;\
fi
@if [ ! -z $(STDERR_EXP2) ] ; then \
if $(NEGATE) grep -qF $(STDERR_EXP2) < $(ROOT)/$*.stderr ; then true ; else \
echo 'Searched for '$(STDERR_EXP2)' NEGATE = $(NEGATE)' ;\
tail --bytes=5000 $(ROOT)/$*.stderr ;\
exit 1 ;\
fi \
fi
@touch $@

Expand Down
6 changes: 6 additions & 0 deletions test/exceptions/src/message_with_null.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module message_with_null;

void main()
{
throw new Exception("hello\0 world!");
}