Comments (10)
If to use -betterC switch then leak disappears
echo "extern(C) int main() { return 0; }" > test.d
ldc test.d -betterC
valgrind ./test
Outputs:
==41353== Memcheck, a memory error detector
==41353== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==41353== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==41353== Command: ./test
==41353==
==41353==
==41353== HEAP SUMMARY:
==41353== in use at exit: 0 bytes in 0 blocks
==41353== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==41353==
==41353== All heap blocks were freed -- no leaks are possible
==41353==
==41353== For lists of detected and suppressed errors, rerun with: -s
==41353== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
from ldc.
and sanitizers? (address, memory, thread)
from ldc.
Havent tested, not sure how to though
from ldc.
Havent tested, not sure how to though
Try:
$> export ASAN_OPTIONS=abort_on_error=0:fast_unwind_on_malloc=0:detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1
$> ldc2 hello.d -fsanitize=memory
$> ./hello
## Output empty/none or stacktrce?
Reference
from ldc.
Nothing
But running resulting binary with valgrind kills my pc
from ldc.
isn't leaking intentional in DMD and LDC without -lowmem
?
i misunderstood, never mind.
from ldc.
These are probably just harmless little leaks in upstream druntime, where nobody bothered cleaning up a few bytes. E.g., for
==39912== 32 bytes in 1 blocks are possibly lost in loss record 3 of 4
==39912== at 0x4843788: malloc (vg_replace_malloc.c:442)
==39912== by 0x4D3B7CA: core.internal.gc.impl.conservative.gc.initialize() (in /usr/lib/libdruntime-ldc-shared.so.107.1
See https://github.com/dlang/dmd/blob/274eec89f4ce7f34a1776e3ac1b1e9c82de90811/druntime/src/core/internal/gc/impl/conservative/gc.d#L142 - that ConservativeGC
object itself is malloc'd during runtime/GC initialization and most likely never freed.
from ldc.
Does this leak occur on another system and/or libc?
Because on the Alpine I didn't have the same problem.
from ldc.
I have no way of checking other platforms
Also not sure about libc, like, what I do with it?
from ldc.
Also not sure about libc, like, what I do with it?
I cited libc because Alpine uses musl and not glibc.
It would be interesting to know if this applies only to glibc, or even only to archlinux.
If you have docker installed, you can test it:
docker-ldc2
# ldc2 master - upstream (musl fixed)
$ docker pull kassany/alpine-ldc2
$ docker run --rm -it -v $(pwd):/app -w /app kassany/alpine-ldc2:latest ash
# for musl can build `ldc2/ldmd2 -static foo.d` (libunwind-static already installed)
# run valgrind (your host) in static-foo.
from ldc.
Related Issues (20)
- LDC 1.38.0 crash on default parameter with `new` HOT 2
- WebAssembly: doesn't support emscripten data layout HOT 1
- lit test broken for Python >= 3.12 HOT 2
- core.stdc.stdlib.d is missing some type definitions for wasm32-unknown-unknown-wasm target HOT 5
- Memory leak in rt.minfo according to ASAN HOT 3
- Time trace large amounts of time spent in writing of files HOT 8
- stat_t has wrong size for Android armv7a HOT 2
- Struct with constructor in member returned using pointer on Windows x64 HOT 1
- Segmentation fault: ldc2 compiled tinyscheme-1.42 (DMD works fine) HOT 1
- No error when using params in @naked functions HOT 4
- Shadowed static assert error in the compiler output HOT 8
- musl libc requires `-link-defaultlib-debug -frame-pointer=all` to show line information in backtrace
- Support CMAKE_INSTALL_LIBDIR ? HOT 1
- LLVM ERROR when cross-compiling to arm64 with -g -flto HOT 1
- Reduce output of `ldc2 --version`
- `core.atomic.atomicStore` and `core.atomic.atomicLoad` calls itself recursively HOT 4
- ldc expects shared libraries even thought explicitly asks for a static build HOT 2
- remove or de-UB --release from the CLI HOT 12
- Support for newer LLVM versions for C++ bootstrap branch? HOT 7
- Wish: implement %ldccurrentpath% variable for ldc2.conf HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ldc.