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

valgrind errors when reading files #296

Open
Anton-4 opened this issue Dec 23, 2024 · 0 comments
Open

valgrind errors when reading files #296

Anton-4 opened this issue Dec 23, 2024 · 0 comments

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 23, 2024

app [main!] { pf: platform "../platform/main.roc" }

import pf.File

parse = \s ->
    s
    |> Str.splitOn "\n"
    |> List.dropFirst 1
    |> List.dropIf Str.isEmpty

main! = \_args ->
    dbg (File.read_utf8! "file" |> Result.withDefault "failed" |> parse)
    Ok {}

This was originally discovered in #295

Valgrind output:

❯ roc build examples/temp.roc --linker=legacy
0 errors and 0 warnings found in 220 ms while successfully building:

    examples/temp

basic-cli on  main [!?] is 📦 v0.0.1 via 🦀 v1.82.0 via ❄️  impure (nix-shell-env) 
❯ valgrind ./examples/temp 
==58896== Memcheck, a memory error detector
==58896== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==58896== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==58896== Command: ./examples/temp
==58896== 
==58896== Invalid read of size 8
==58896==    at 0x1344DD: decrement_refcounted_ptr_8 (roc_app:0)
==58896==    by 0x13449D: ??? (roc_app:0)
==58896==    by 0x1349F1: #Attr_#generic_rc_by_ref_1_dec (roc_app:0)
==58896==    by 0x1349F1: ??? (roc_app:0)
==58896==    by 0x12D9C8: Inspect_inspect_36ded37b63679dfb9096703c22eba74b3449a854bc97ac179ba6ffbbbaa21 (roc_app:0)
==58896==    by 0x1330B1: Inspect_toStr_9ddbc9a5a6ab79818cf720ec32ba1aeb5838e37cd919c2ff6b897d7d866d5c7 (roc_app:0)
==58896==    by 0x1331C0: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==  Address 0x4b786d0 is 0 bytes inside a block of size 1,006 free'd
==58896==    at 0x4848BD4: free (in /nix/store/qy8niksnmmfd1zim8kdw020l53agbagd-valgrind-3.23.0/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==58896==    by 0x129BA5: ??? (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x134553: decrement_refcounted_ptr_8 (roc_app:0)
==58896==    by 0x13449D: ??? (roc_app:0)
==58896==    by 0x1349F1: #Attr_#generic_rc_by_ref_1_dec (roc_app:0)
==58896==    by 0x1349F1: ??? (roc_app:0)
==58896==    by 0x12D9C8: Inspect_inspect_36ded37b63679dfb9096703c22eba74b3449a854bc97ac179ba6ffbbbaa21 (roc_app:0)
==58896==    by 0x1330B1: Inspect_toStr_9ddbc9a5a6ab79818cf720ec32ba1aeb5838e37cd919c2ff6b897d7d866d5c7 (roc_app:0)
==58896==    by 0x1331C0: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==  Block was alloc'd at
==58896==    at 0x48457D9: malloc (in /nix/store/qy8niksnmmfd1zim8kdw020l53agbagd-valgrind-3.23.0/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==58896==    by 0x1DFCCC: roc_std::roc_list::RocList<T>::extend_from_slice (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x1930CC: roc_fx_file_read_bytes (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x136C39: roc_fx_file_read_bytes_fastcc_wrapper (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x130CC0: Host_file_read_bytes!_df662f4854c7c5a297d6c339e28fd51ddc944983db9bc7f012ab2c1c69a52db6 (roc_app:0)
==58896==    by 0x12DE07: Path_read_utf8!_46df57811ab9544a1f9313aab57b6ce51825f299caf5a1ffe2569412f3ed972 (roc_app:0)
==58896==    by 0x12EC00: File_read_utf8!_539d94cac9151288c18279a5f1573e8d65d66aeb5922fa6ed8cbc577893894 (roc_app:0)
==58896==    by 0x133124: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896== 
==58896== Invalid write of size 8
==58896==    at 0x134506: decrement_refcounted_ptr_8 (roc_app:0)
==58896==    by 0x13449D: ??? (roc_app:0)
==58896==    by 0x1349F1: #Attr_#generic_rc_by_ref_1_dec (roc_app:0)
==58896==    by 0x1349F1: ??? (roc_app:0)
==58896==    by 0x12D9C8: Inspect_inspect_36ded37b63679dfb9096703c22eba74b3449a854bc97ac179ba6ffbbbaa21 (roc_app:0)
==58896==    by 0x1330B1: Inspect_toStr_9ddbc9a5a6ab79818cf720ec32ba1aeb5838e37cd919c2ff6b897d7d866d5c7 (roc_app:0)
==58896==    by 0x1331C0: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==  Address 0x4b786d0 is 0 bytes inside a block of size 1,006 free'd
==58896==    at 0x4848BD4: free (in /nix/store/qy8niksnmmfd1zim8kdw020l53agbagd-valgrind-3.23.0/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==58896==    by 0x129BA5: ??? (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x134553: decrement_refcounted_ptr_8 (roc_app:0)
==58896==    by 0x13449D: ??? (roc_app:0)
==58896==    by 0x1349F1: #Attr_#generic_rc_by_ref_1_dec (roc_app:0)
==58896==    by 0x1349F1: ??? (roc_app:0)
==58896==    by 0x12D9C8: Inspect_inspect_36ded37b63679dfb9096703c22eba74b3449a854bc97ac179ba6ffbbbaa21 (roc_app:0)
==58896==    by 0x1330B1: Inspect_toStr_9ddbc9a5a6ab79818cf720ec32ba1aeb5838e37cd919c2ff6b897d7d866d5c7 (roc_app:0)
==58896==    by 0x1331C0: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==  Block was alloc'd at
==58896==    at 0x48457D9: malloc (in /nix/store/qy8niksnmmfd1zim8kdw020l53agbagd-valgrind-3.23.0/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==58896==    by 0x1DFCCC: roc_std::roc_list::RocList<T>::extend_from_slice (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x1930CC: roc_fx_file_read_bytes (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x136C39: roc_fx_file_read_bytes_fastcc_wrapper (in /home/username/gitrepos/basic-cli/examples/temp)
==58896==    by 0x130CC0: Host_file_read_bytes!_df662f4854c7c5a297d6c339e28fd51ddc944983db9bc7f012ab2c1c69a52db6 (roc_app:0)
==58896==    by 0x12DE07: Path_read_utf8!_46df57811ab9544a1f9313aab57b6ce51825f299caf5a1ffe2569412f3ed972 (roc_app:0)
==58896==    by 0x12EC00: File_read_utf8!_539d94cac9151288c18279a5f1573e8d65d66aeb5922fa6ed8cbc577893894 (roc_app:0)
==58896==    by 0x133124: #UserApp_main!_c6e34737223a4b123e4ef4b086ad92b3ead64b519536ae28b552b4718b7124e (roc_app:0)
==58896==    by 0x12ECDF: _main_for_host!_c852b6d75d2364d70d094699f8a9cda9129d5310ed82ea45564f47a9 (roc_app:0)
==58896==    by 0x12EDA4: roc__main_for_host_1_exposed_generic (roc_app:0)
==58896==    by 0x137DAB: main (in /home/username/gitrepos/basic-cli/examples/temp)
==58896== 
[examples/temp.roc:12] File.read_utf8! "file" |> Result.withDefault "failed" |> parse = ["XXX"]
==58896== 
==58896== HEAP SUMMARY:
==58896==     in use at exit: 95 bytes in 2 blocks
==58896==   total heap usage: 10 allocs, 8 frees, 2,447 bytes allocated
==58896== 
==58896== LEAK SUMMARY:
==58896==    definitely lost: 72 bytes in 1 blocks
==58896==    indirectly lost: 23 bytes in 1 blocks
==58896==      possibly lost: 0 bytes in 0 blocks
==58896==    still reachable: 0 bytes in 0 blocks
==58896==         suppressed: 0 bytes in 0 blocks
==58896== Rerun with --leak-check=full to see details of leaked memory
==58896== 
==58896== For lists of detected and suppressed errors, rerun with: -s
==58896== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
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

1 participant