Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaking issues #5

Open
25077667 opened this issue Oct 6, 2023 · 2 comments
Open

Memory leaking issues #5

25077667 opened this issue Oct 6, 2023 · 2 comments

Comments

@25077667
Copy link
Contributor

25077667 commented Oct 6, 2023

When I turn on the -fsanitize=address flag for clang++, and make check.

The aes.elf stage said:

Running build/aes.elf ...
Test results
AES-128 ECB encryption: PASSED!
AES-128 ECB decryption: PASSED!
AES-128 CBC encryption: PASSED!
AES-128 CBC decryption: PASSED!
AES-128 CFB encryption: PASSED!
AES-128 CFB decryption: PASSED!
AES-128 OFB encryption: PASSED!
AES-128 OFB decryption: PASSED!
AES-128 CTR encryption: PASSED!
AES-128 CTR decryption: PASSED!
AES-128 XTS encryption: PASSED!
AES-128 XTS decryption: PASSED!
AES-128 plaintext CMAC: PASSED!
AES-128 Poly1305 auth.: PASSED!
AES-128 GCM encryption: PASSED!
AES-128 GCM decryption: PASSED!
AES-128 CCM encryption: PASSED!
AES-128 CCM decryption: PASSED!
AES-128 OCB encryption: PASSED!
AES-128 OCB decryption: PASSED!
AES-128 SIV encryption: PASSED!
AES-128 SIV decryption: PASSED!
AES-128 GCMSIV encrypt: PASSED!
AES-128 GCMSIV decrypt: PASSED!
AES-128 EAX encryption: PASSED!
AES-128 EAX decryption: PASSED!
AES-128 FF1 encryption: PASSED!
AES-128 FPE decryption: PASSED!
AES-128 key wrapping  : PASSED!
AES-128 key unwrapping: PASSED!
+-> Let's do some extra tests
AES-128 OCB encryption: PASSED!
AES-128 OCB decryption: PASSED!
AES-128 GCMSIV encrypt: PASSED!
AES-128 GCMSIV decrypt: PASSED!
AES-128 GCMSIV encrypt: PASSED!
AES-128 GCMSIV decrypt: PASSED!
AES-128 SIV encryption: PASSED!
AES-128 SIV decryption: PASSED!
AES-128 SIV encryption: PASSED!
AES-128 SIV decryption: PASSED!
AES-128 EAX encryption: PASSED!
AES-128 EAX decryption: PASSED!
AES-128 EAX encryption: PASSED!
AES-128 EAX decryption: PASSED!
AES-128 Poly1305 auth.: PASSED!
AES-128 Poly1305 auth.: PASSED!

=================================================================
==33140==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10065 byte(s) in 970 object(s) allocated from:
    #0 0x560ebde7fc82 in operator new(unsigned long) (me/git/rv32jit/build/rv32jit+0x16ac82) (BuildId: d5f40ebc9e253e729fadf45522801b8f8372a477)
    #1 0x560ebdee25ed in dbt::qir::Builder::CreateVGPR(dbt::qir::VType) const (me/git/rv32jit/build/rv32jit+0x1cd5ed) (BuildId: d5f40ebc9e253e729fadf45522801b8f8372a477)

And nqueens.elf said:

Running build/nqueens.elf ...
<---  N-Queens Solutions  --->
 N:        Total       Unique
 2:            0            0
 3:            0            0
 4:            2            1
 5:           10            2
 6:            4            1
 7:           40            6
 8:           92           12
 9:          352           46
10:          724           92
11:         2680          341
12:        14200         1787
13:        73712         9233
14:       365596        45752
15:      2279184       285053

=================================================================
==33144==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1343 byte(s) in 293 object(s) allocated from:
    #0 0x559fd52d8c82 in operator new(unsigned long) (me/git/rv32jit/build/rv32jit+0x16ac82) (BuildId: d5f40ebc9e253e729fadf45522801b8f8372a477)
    #1 0x559fd533b5ed in dbt::qir::Builder::CreateVGPR(dbt::qir::VType) const (me/git/rv32jit/build/rv32jit+0x1cd5ed) (BuildId: d5f40ebc9e253e729fadf45522801b8f8372a477)

and so on.

Would you like to use the smart pointer to replace the new operator?
(Actually, it would be std::shared_ptr and std::weak_ptr, I found there are some caching mechanisms that would need some gc here)

@jserv
Copy link
Owner

jserv commented Oct 6, 2023

Would you like to use the smart pointer to replace the new operator? (Actually, it would be std::shared_ptr and std::weak_ptr, I found there are some caching mechanisms that would need some gc here)

Please go ahead with C++ smart pointers. Do change the necessary macros accordingly.

@pukhovv
Copy link

pukhovv commented Jun 28, 2024

QuickIR compiler uses Arena chunks, it is just a mistake, use Arena instead of STL allocator :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants