Commit graph

7 commits

Author SHA1 Message Date
Vladimir Panteleev
7cdae6e3bb
Add Valgrind GC integration (#15304)
* rt.minfo: Avoid calling realloc with size 0

This is not portable, and memcheck complains about this.

* Add C Valgrind API

Add the BSD-licensed C header files which provide the API for
controlling Valgrind from within programs executed under it.

The files are from Valgrind v3.21.0.

* Add some D bindings for the Valgrind C API

We will use these in the GC implementation to tell Valgrind which
memory operations are OK or not.

* Silence Valgrind warnings caused by GC marking

Allow the conservative GC to scan memory, whether it has been
initialized by the application or not.

* Add test suite for Valgrind

* Unify VALGRIND with MEMSTOMP

The two share the same goal: mark memory which should not be accessed
any more.

* Mask "invalid" access to free lists

The GC stores free lists in the cells of the objects on the list.

We would like to allow the GC to work with these lists, but still
raise a warning if application code attempts to access them.

* Distinguish between writable and unwritable invalidation

Freshly allocated memory should be writable but not readable.

Explicitly deallocated or GC-ed memory should be neither readable or
writable.

* Add use-after-free test

* Invalidate freshly-allocated memory

* Integrate VALGRIND with SENTINEL

* Fix reporting of arrays of structs with destructors

* Re-invalidate reused blocks during malloc/calloc

* Add Changelog entry

* .pre-commit-config.yaml: Exempt vendored files

* etc.valgrind.valgrind: Propagate return values of the vbits functions

* etc.valgrind.valgrind: Add documentation for functions

Copy/adapt the documentation in memcheck.h.

* druntime/test/valgrind: Add no_use_after_gc test

* ci/cirrusci.sh: Install Valgrind on Linux

Run the Druntime Valgrind integration tests.

libc6-dbg is needed to allow Valgrind to redirect certain functions.

* etc.valgrind.valgrind: Add @nogc

Although the GC is the primary user, this is not a restriction of
these Valgrind API wrappers.

* druntime/test/valgrind: Fix no_use_after_gc test with -release

Trick the optimizer to pretend we're doing something with the result
of those invalid memory accesses.
2023-06-15 01:01:42 -07:00
Walter Bright
481e169269
add core.factory (#14888) 2023-02-22 11:13:32 +02:00
Ömer Faruk IRMAK
34c8962cab Add core.builtins to SRCS 2022-10-26 13:28:54 +01:00
Iain Buclaw
8f00b6dac7 make: Put windows build files in the toplevel generated directory 2022-10-12 19:54:12 +02:00
Teodor Dutu
d0a367e98c
Translate _d_arraysetassign to template (#14382)
- Implement template `_d_arraysetassign`
- Lower array asignments to a single element to the above template
- Remove old lowering from e2ir.d
- Remove the old `_d_arraysetassign` hook and its file rt/arrayassign.d
- Add test for assigning a struct with a `@disabled` postblit

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
2022-09-15 23:54:50 +03:00
Teodor Dutu
c83dff2e1b
Translate _d_arrayassign{,_l,_r} to templates (#14310)
- Implement template `_d_arrayassign{_l,_r}`
- Lower array asignment expressions to the above templates
- Remove old lowering from e2ir.d
- Remove the old `_d_arrayassign{,_l,_r}` hooks
- Merge the usage of `_d_arrayassign` with that of `_d_arrayassign_l`

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
2022-08-02 11:11:40 +03:00
Iain Buclaw
69ab16a7e8 Merge dlang/druntime repository into dlang/dmd 2022-07-09 18:53:15 +02:00