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

[BUG] Popping a String from a dictionary then using the value leads to a double free crash. #2756

Open
thatstoasty opened this issue May 20, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed mojo-repo Tag all issues with this label [stdlib] core-library-q2-2024

Comments

@thatstoasty
Copy link

thatstoasty commented May 20, 2024

Bug description

Popping a String from a dictionary, then using the value leads to a double free crash.

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

Minimal reproducible example:

fn main() raises:
    var context = Dict[String, String]()
    context["a"] = "b"
 
    print(context.pop("a"))
mojo(76499,0x1eb727ac0) malloc: Double free of object 0x13a7283b0
mojo(76499,0x1eb727ac0) malloc: *** set a breakpoint in malloc_error_break to debug
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0. Program arguments: mojo run test.mojo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mojo 0x0000000104513db4 llvm_strlcpy + 51480
1 mojo 0x00000001045120a0 llvm_strlcpy + 44036
2 mojo 0x00000001045144a0 llvm_strlcpy + 53252
3 libsystem_platform.dylib 0x0000000183a4b584 _sigtramp + 56
4 libsystem_pthread.dylib 0x0000000183a1ac20 pthread_kill + 288
5 libsystem_c.dylib 0x0000000183927a20 abort + 180
6 libsystem_malloc.dylib 0x0000000183837aa8 malloc_vreport + 896
7 libsystem_malloc.dylib 0x000000018385bea8 malloc_zone_error + 104
8 libsystem_malloc.dylib 0x000000018385ad00 free_tiny_botch + 40
9 libKGENCompilerRTShared.dylib 0x000000010747ba7c KGEN_CompilerRT_AlignedFree + 156
10 libKGENCompilerRTShared.dylib 0x0000000300004a58 KGEN_CompilerRT_AlignedFree + 8467812472
11 mojo 0x00000001048a2394 __jit_debug_register_code + 1013256
12 mojo 0x000000010447436c
13 mojo 0x000000010445cc6c
14 dyld 0x00000001836920e0 start + 2360
mojo crashed!
Please file a bug report.
[76501:2834223:20240519,202919.017732:WARNING in_range_cast.h:38] value -634136515 out of range
[76501:2834223:20240519,202919.021409:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)
[1] 76499 abort mojo run test.mojo

System information

- What OS did you do install Mojo on ? MacOS 14.4.1
- Provide version information for Mojo by pasting the output of `mojo -v` mojo 2024.5.1905 (46b7e7ee)
- Provide Modular CLI version by pasting the output of `modular -v` modular 0.7.1 (28ddab26)
@thatstoasty thatstoasty added bug Something isn't working mojo-repo Tag all issues with this label labels May 20, 2024
@JoeLoser JoeLoser added the mojo-stdlib Tag for issues related to standard library label May 22, 2024
@ematejska ematejska removed the mojo-stdlib Tag for issues related to standard library label May 22, 2024
helehex added a commit to helehex/mojo that referenced this issue May 22, 2024
Signed-off-by: Max Brylski <helehex@gmail.com>
@JoeLoser JoeLoser added [stdlib] core-library-q2-2024 help wanted Extra attention is needed labels May 22, 2024 — with Linear
@rd4com
Copy link

rd4com commented May 26, 2024

Just an additional information to solve the bug ,in reference to #2822, if we change return entry_value.value^ to return entry_value.value it fix the issue but probably create another one (returning a copy instead of an Rvalue (owned value)).
(ping to @JoeLoser )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed mojo-repo Tag all issues with this label [stdlib] core-library-q2-2024
Projects
None yet
Development

No branches or pull requests

4 participants