Giter Club home page Giter Club logo

Comments (10)

al1-ce avatar al1-ce commented on August 26, 2024

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.

kassane avatar kassane commented on August 26, 2024

and sanitizers? (address, memory, thread)

from ldc.

al1-ce avatar al1-ce commented on August 26, 2024

Havent tested, not sure how to though

from ldc.

kassane avatar kassane commented on August 26, 2024

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.

al1-ce avatar al1-ce commented on August 26, 2024

Nothing
But running resulting binary with valgrind kills my pc

from ldc.

yellowsink avatar yellowsink commented on August 26, 2024

isn't leaking intentional in DMD and LDC without -lowmem?
i misunderstood, never mind.

from ldc.

kinke avatar kinke commented on August 26, 2024

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.

kassane avatar kassane commented on August 26, 2024

Does this leak occur on another system and/or libc?
Because on the Alpine I didn't have the same problem.

from ldc.

al1-ce avatar al1-ce commented on August 26, 2024

I have no way of checking other platforms

Also not sure about libc, like, what I do with it?

from ldc.

kassane avatar kassane commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.