cell_dependencies$d1c8fa7e-8874-45e3-a398-e1fa2322af32precedence_heuristic cell_id$d1c8fa7e-8874-45e3-a398-e1fa2322af32downstream_cells_mapupstream_cells_map@md_strgetindex$35ad233c-a500-461a-af82-855d56792841precedence_heuristiccell_id$35ad233c-a500-461a-af82-855d56792841downstream_cells_mapupstream_cells_mapPkg$47f92d66-0834-4f8d-9bdf-172c55e93ccePkg.activate$b0efbf09-53d7-40b2-af63-49f794336e9fprecedence_heuristic cell_id$b0efbf09-53d7-40b2-af63-49f794336e9fdownstream_cells_mapvalgrind_debug$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8upstream_cells_map@md_strCoreasidePlutoRunnerPlutoRunner.create_bondCore.applicablegetindexBase.get@bindBaseFoldableCheckBox$e3053cb5-186d-4c98-86c7-609be4a7c8dcprecedence_heuristic cell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dcdownstream_cells_mapupstream_cells_mapout_of_bounds$d50aa7f3-9c15-412e-82c2-f870aab8ffb0compile_and_run$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378precedence_heuristic cell_id$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378downstream_cells_mapupstream_cells_map@md_strgetindex$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60precedence_heuristic cell_id$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60downstream_cells_mapupstream_cells_map@md_strgetindex$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbprecedence_heuristiccell_id$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbdownstream_cells_mapMyUtilsPlutoUIExperimentalLayoutLuxorPlutoTeachingToolsupstream_cells_map$d50aa7f3-9c15-412e-82c2-f870aab8ffb0precedence_heuristic cell_id$d50aa7f3-9c15-412e-82c2-f870aab8ffb0downstream_cells_mapout_of_bounds$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0$e3053cb5-186d-4c98-86c7-609be4a7c8dcupstream_cells_mapExample$52ddb3b6-0f88-4596-a480-d4d17489292cprecedence_heuristic cell_id$52ddb3b6-0f88-4596-a480-d4d17489292cdownstream_cells_mapupstream_cells_map@md_str=>imggetindex$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bprecedence_heuristic cell_id$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bdownstream_cells_mapupstream_cells_map@md_strgetindex$5892921c-b019-418c-ba01-3d7a4e4697b3precedence_heuristic cell_id$5892921c-b019-418c-ba01-3d7a4e4697b3downstream_cells_mapupstream_cells_map@md_strgetindex$18e1147f-ef60-4368-819b-4e41c1b904dfprecedence_heuristic cell_id$18e1147f-ef60-4368-819b-4e41c1b904dfdownstream_cells_mapupstream_cells_mapBaseBase.Docs.HTML@html_str$9afe0855-162f-4234-8001-610e08e39bb0precedence_heuristic cell_id$9afe0855-162f-4234-8001-610e08e39bb0downstream_cells_mapupstream_cells_map@md_strgetindex$7a9a1afc-16a3-11f0-2474-67fc85a76676precedence_heuristic cell_id$7a9a1afc-16a3-11f0-2474-67fc85a76676downstream_cells_mapupstream_cells_mapheader$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0precedence_heuristic cell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0downstream_cells_mapupstream_cells_mapout_of_bounds$d50aa7f3-9c15-412e-82c2-f870aab8ffb0compile_and_run$3b928e29-a281-4dc2-9429-41e7d98dad54precedence_heuristic cell_id$3b928e29-a281-4dc2-9429-41e7d98dad54downstream_cells_mapupstream_cells_map@md_strgetindex$47f92d66-0834-4f8d-9bdf-172c55e93cceprecedence_heuristiccell_id$47f92d66-0834-4f8d-9bdf-172c55e93ccedownstream_cells_mapPkg$35ad233c-a500-461a-af82-855d56792841$a843fc18-5290-414a-a5db-dacd4ac88f1dupstream_cells_map$dfb72971-ccf6-46ec-b686-37e071bd9598precedence_heuristic cell_id$dfb72971-ccf6-46ec-b686-37e071bd9598downstream_cells_mapupstream_cells_map@md_strgetindex$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8precedence_heuristic cell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8downstream_cells_mapupstream_cells_mapcompile_and_runStringvalgrind$4790109e-06b0-4518-a95f-ed9ca8b5f595valgrind_debug$b0efbf09-53d7-40b2-af63-49f794336e9f$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fprecedence_heuristic cell_id$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fdownstream_cells_mapupstream_cells_map@md_strgetindex$d87d73d9-d9d8-46e9-9599-0daa7fa95e9cprecedence_heuristic cell_id$d87d73d9-d9d8-46e9-9599-0daa7fa95e9cdownstream_cells_mapupstream_cells_map@md_strgetindex$a843fc18-5290-414a-a5db-dacd4ac88f1dprecedence_heuristic cell_id$a843fc18-5290-414a-a5db-dacd4ac88f1ddownstream_cells_mapupstream_cells_mapPkg$47f92d66-0834-4f8d-9bdf-172c55e93ccePkg.instantiate$4790109e-06b0-4518-a95f-ed9ca8b5f595precedence_heuristic cell_id$4790109e-06b0-4518-a95f-ed9ca8b5f595downstream_cells_mapvalgrind$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8upstream_cells_mapExample$810cdd19-7e3f-4cf4-a337-d9c1244e96ceprecedence_heuristic cell_id$810cdd19-7e3f-4cf4-a337-d9c1244e96cedownstream_cells_mapupstream_cells_map@md_strgetindexcell_execution_order$47f92d66-0834-4f8d-9bdf-172c55e93cce$35ad233c-a500-461a-af82-855d56792841$10e3b9fb-fe77-4106-a512-74f4d7d0cfbb$7a9a1afc-16a3-11f0-2474-67fc85a76676$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3b$810cdd19-7e3f-4cf4-a337-d9c1244e96ce$d87d73d9-d9d8-46e9-9599-0daa7fa95e9c$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60$d1c8fa7e-8874-45e3-a398-e1fa2322af32$52ddb3b6-0f88-4596-a480-d4d17489292c$b0efbf09-53d7-40b2-af63-49f794336e9f$4790109e-06b0-4518-a95f-ed9ca8b5f595$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8$dfb72971-ccf6-46ec-b686-37e071bd9598$5892921c-b019-418c-ba01-3d7a4e4697b3$9e9a0b57-30ce-4c9c-b0f5-a111f692d13f$9afe0855-162f-4234-8001-610e08e39bb0$3b928e29-a281-4dc2-9429-41e7d98dad54$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378$d50aa7f3-9c15-412e-82c2-f870aab8ffb0$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0$e3053cb5-186d-4c98-86c7-609be4a7c8dc$18e1147f-ef60-4368-819b-4e41c1b904df$a843fc18-5290-414a-a5db-dacd4ac88f1dlast_hot_reload_timeprocess_statusreadypath6/home/runner/work/LEPL1503/LEPL1503/Lectures/Cours5.jlpluto_versionv0.20.21cell_order$7a9a1afc-16a3-11f0-2474-67fc85a76676$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3b$810cdd19-7e3f-4cf4-a337-d9c1244e96ce$d87d73d9-d9d8-46e9-9599-0daa7fa95e9c$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60$d1c8fa7e-8874-45e3-a398-e1fa2322af32$52ddb3b6-0f88-4596-a480-d4d17489292c$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8$b0efbf09-53d7-40b2-af63-49f794336e9f$4790109e-06b0-4518-a95f-ed9ca8b5f595$dfb72971-ccf6-46ec-b686-37e071bd9598$5892921c-b019-418c-ba01-3d7a4e4697b3$9e9a0b57-30ce-4c9c-b0f5-a111f692d13f$9afe0855-162f-4234-8001-610e08e39bb0$3b928e29-a281-4dc2-9429-41e7d98dad54$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378$e3053cb5-186d-4c98-86c7-609be4a7c8dc$d50aa7f3-9c15-412e-82c2-f870aab8ffb0$18e1147f-ef60-4368-819b-4e41c1b904df$47f92d66-0834-4f8d-9bdf-172c55e93cce$35ad233c-a500-461a-af82-855d56792841$a843fc18-5290-414a-a5db-dacd4ac88f1d$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbpublished_objectsnbpkgwaiting_for_permission,waiting_for_permission_but_probably_disabled²installed_versionsterminal_outputsenabled¬instantiated÷restart_recommended_msgrestart_required_msginstall_time_nsbusy_packagescell_inputs$d1c8fa7e-8874-45e3-a398-e1fa2322af32cell_id$d1c8fa7e-8874-45e3-a398-e1fa2322af32code7md"## Vérifiez qu'il n'y a pas de fuites de mémoires"metadatashow_logsèdisabled®skip_as_script«code_folded$35ad233c-a500-461a-af82-855d56792841cell_id$35ad233c-a500-461a-af82-855d56792841codePkg.activate(".")metadatashow_logsèdisabled®skip_as_script«code_folded$b0efbf09-53d7-40b2-af63-49f794336e9fcell_id$b0efbf09-53d7-40b2-af63-49f794336e9fcodeaside( Foldable( md"Pourquoi `valgrind` ne donne-t-il pas le numéro de ligne ?", md"On n'a pas compilé avec `-g` ! On essaie avec `-g` ? $(@bind valgrind_debug CheckBox())", ), v_offset = -300, )metadatashow_logsèdisabled®skip_as_script«code_folded$e3053cb5-186d-4c98-86c7-609be4a7c8dccell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dccode|compile_and_run(out_of_bounds, valgrind = false, verbose = true, cflags = ["-Wno-array-bounds", "-fsanitize=address", "-g"])metadatashow_logsèdisabled®skip_as_script«code_folded$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378cell_id$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378codemd"## Exemple avec sanitize"metadatashow_logsèdisabled®skip_as_script«code_folded$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60cell_id$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60codemd""" * Pour valider votre contribution au projet, il est nécessaire que vous ayez des merge requests en votre nom qui sont mergées avec des commits également en votre nom * Ces merge requests doivent avoir été finies (donc passer les tests) puis mergées * Elles doivent apporter une contribution significatives au code, par exemple pas juste modifier le README ou reformatter * L'excuse du peer coding (vous programmez à deux sur un ordinateur) n'est pas valide * Ne pas savoir exécuter le code chez soi n'est pas une excuse. Git est facile à installer sous n'importe quelle platforme et les tests s'exécute sur le runner GitLab. """metadatashow_logsèdisabled®skip_as_script«code_folded$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbcell_id$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbcodeMusing Luxor, PlutoUI, PlutoUI.ExperimentalLayout, MyUtils, PlutoTeachingToolsmetadatashow_logsèdisabled®skip_as_script«code_folded$d50aa7f3-9c15-412e-82c2-f870aab8ffb0cell_id$d50aa7f3-9c15-412e-82c2-f870aab8ffb0code+out_of_bounds = Example("out_of_bounds.c");metadatashow_logsèdisabled®skip_as_script«code_folded$52ddb3b6-0f88-4596-a480-d4d17489292ccell_id$52ddb3b6-0f88-4596-a480-d4d17489292ccodemd""" Lors de la correction, nous vérifierons qu'il n'y a pas de fuites de mémoire avec [Valgrind $(img("https://valgrind.org/images/st-george-dragon.png", :height => "60"))](https://valgrind.org/) """metadatashow_logsèdisabled®skip_as_script«code_folded$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bcell_id$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bcodemd"## Clarifications projet"metadatashow_logsèdisabled®skip_as_script«code_folded$5892921c-b019-418c-ba01-3d7a4e4697b3cell_id$5892921c-b019-418c-ba01-3d7a4e4697b3codeNmd""" On ne partage normalement pas de fichiers binaires (ex : `.o`) par `git` car ce n'est pas portable (ex : ce `.o` ne marche pas sur Mac OS si compilé sur un Raspberry). Lorsque des fichiers auto-générés apparaissent dans la sortie de `git status`, ajoutez-les dans le `.gitignore`. Supprimez-les de git avec `git rm` s'ils ont été ajouté précédemment par accident, ce qui ne devrait pas arriver si `git add -p` est toujours utilisé au lieu de `git add .`. C'est une bonne chose d'écrire des unit tests, mais comme les signatures des fonctions sont libres, nous utiliserons l'interface uniformisée en ligne de commande pour testez votre code. Assurez-vous qu'elle fonctionne comme demandée. > Le Makefile génère un exécutable. Vous pouvez l'utiliser de la façon suivante : > > ``` > ./ [arguments] > ``` """metadatashow_logsèdisabled®skip_as_script«code_folded$18e1147f-ef60-4368-819b-4e41c1b904dfcell_id$18e1147f-ef60-4368-819b-4e41c1b904dfcodeahtml"

The End

"metadatashow_logsèdisabled®skip_as_script«code_folded$9afe0855-162f-4234-8001-610e08e39bb0cell_id$9afe0855-162f-4234-8001-610e08e39bb0codemd""" * Ne pas oublier d'utiliser `-g` lors de la compilation * `lldb` : développé par LLVM comme `clang` mais fonctionne aussi avec des binaires compilés avec `gcc`, plus facile à installer sur Mac OS * `gdb` : développé par GNU comme `gcc` mais fonctionne aussi avec des binaires compilés avec `clang` * Il existe des interfaces graphiques pour ces débogueur, ex : [Seer](https://github.com/epasveer/seer) (`apt install seergdb`), [VSCode](https://code.visualstudio.com/docs/cpp/cpp-debug), [lldbg](https://github.com/zmeadows/lldbg), [gdbgui](https://www.gdbgui.com), etc. * Utiliser un débogueur, c'est un bon réflex ! * Utilisez `-fsanitize=address` à la compilation pour que les bornes soient vérifiées. - Le code est peut-être un peu moins rapide donc c'est à désactiver pour les mesures - mais il n'y a pas de bonne raison de ne pas l'utiliser dans la phase de développement! """metadatashow_logsèdisabled®skip_as_script«code_folded$7a9a1afc-16a3-11f0-2474-67fc85a76676cell_id$7a9a1afc-16a3-11f0-2474-67fc85a76676codeMheader("LEPL1503/LSINC1503 - Cours 5", "O. Bonaventure, B. Legat, M. Baerts")metadatashow_logsèdisabled®skip_as_script«code_folded$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0cell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0codefcompile_and_run(out_of_bounds, valgrind = false, verbose = true, cflags = ["-Wno-array-bounds", "-g"])metadatashow_logsèdisabled®skip_as_script«code_folded$3b928e29-a281-4dc2-9429-41e7d98dad54cell_id$3b928e29-a281-4dc2-9429-41e7d98dad54codemd"## Exemple sans sanitize"metadatashow_logsèdisabled®skip_as_script«code_folded$47f92d66-0834-4f8d-9bdf-172c55e93ccecell_id$47f92d66-0834-4f8d-9bdf-172c55e93ccecodeimport Pkgmetadatashow_logsèdisabled®skip_as_script«code_folded$dfb72971-ccf6-46ec-b686-37e071bd9598cell_id$dfb72971-ccf6-46ec-b686-37e071bd9598codemd"## Interface par fichiers"metadatashow_logsèdisabled®skip_as_script«code_folded$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8cell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8codegcompile_and_run(valgrind, valgrind = true, verbose = true, cflags = valgrind_debug ? ["-g"] : String[])metadatashow_logsèdisabled®skip_as_script«code_folded$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fcell_id$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fcodemd"## Debugging"metadatashow_logsèdisabled®skip_as_script«code_folded$d87d73d9-d9d8-46e9-9599-0daa7fa95e9ccell_id$d87d73d9-d9d8-46e9-9599-0daa7fa95e9ccode(md"## Chacun doit contribuer sur le Git"metadatashow_logsèdisabled®skip_as_script«code_folded$a843fc18-5290-414a-a5db-dacd4ac88f1dcell_id$a843fc18-5290-414a-a5db-dacd4ac88f1dcodePkg.instantiate()metadatashow_logsèdisabled®skip_as_script«code_folded$4790109e-06b0-4518-a95f-ed9ca8b5f595cell_id$4790109e-06b0-4518-a95f-ed9ca8b5f595code!valgrind = Example("valgrind.c");metadatashow_logsèdisabled®skip_as_script«code_folded$810cdd19-7e3f-4cf4-a337-d9c1244e96cecell_id$810cdd19-7e3f-4cf4-a337-d9c1244e96cecodewmd""" * Il est important de lire [la partie multithread du syllabus](https://lepl1503.info.ucl.ac.be/syllabus/theorie/index.html#systemes-multiprocesseurs) pour savoir faire la deuxième partie * Amenez le Raspberry aux séances de TP pour que votre tuteur puissent vérifier que vous savez l'utiliser et que votre code fonctionne dessus. Les mesures devront être faites sur le Raspeberry pour être valable. On ne considère pas les mesures sur une autre plateforme. * N'oubliez de régulièrement récupérer les modifications réalisées sur le dépôt parent. * Rappel : l'utilisation de logiciels d'IA générative tels que chatGPT, GitHub copilot, ... est interdite pour l'écriture de code source en langage C et les reviews. Par ailleurs, les sources d'information externes doivent être systématiquement citées en respectant les normes de référencement bibliographique. """metadatashow_logsèdisabled®skip_as_script«code_foldedënotebook_id$02d19e3e-9184-11f1-95f4-6d0947d6241dbondscell_results$d1c8fa7e-8874-45e3-a398-e1fa2322af32queued¤logsrunning¦outputbodyٜ

Vérifiez qu'il n'y a pas de fuites de mémoires

persist_js_state¤mimetext/htmllast_run_timestampAڝ{has_pluto_hook_features¬rootassigneecell_id$d1c8fa7e-8874-45e3-a398-e1fa2322af32depends_on_disabled_cells§runtime˵published_object_keysdepends_on_skipped_cells§errored$35ad233c-a500-461a-af82-855d56792841queued¤logslinemsgO Activating project at `~/work/LEPL1503/LEPL1503/Lectures` text/plaincell_id$35ad233c-a500-461a-af82-855d56792841kwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/CBqeh/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝl3 has_pluto_hook_features¬rootassigneecell_id$35ad233c-a500-461a-af82-855d56792841depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$b0efbf09-53d7-40b2-af63-49f794336e9fqueued¤logsrunning¦outputbody persist_js_state¤mimetext/htmllast_run_timestampAڝ¯has_pluto_hook_features¬rootassigneecell_id$b0efbf09-53d7-40b2-af63-49f794336e9fdepends_on_disabled_cells§runtime Lwpublished_object_keysdepends_on_skipped_cells§errored$e3053cb5-186d-4c98-86c7-609be4a7c8dcqueued¤logslinemsgٴCompiling : `/home/runner/.julia/artifacts/207eb5b8330e24674fe59b50d72f4b3d946219c8/tools/clang -Wno-array-bounds -fsanitize=address -g /tmp/jl_XL8R4T/main.c -o /tmp/jl_XL8R4T/bin`text/plaincell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dckwargsidMyUtils_6794ab28fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsgRunning : `/tmp/jl_XL8R4T/bin`text/plaincell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dckwargsidMyUtils_0f723ef4fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsgProcessFailedExceptiontext/plaincell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dckwargsidMyUtils_18a9260cfileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelWarnlinemsg ================================================================= ==11639==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f846d20002c at pc 0x55ed1d26bbca bp 0x7ffd790bfbd0 sp 0x7ffd790bfbc8 WRITE of size 4 at 0x7f846d20002c thread T0 #0 0x55ed1d26bbc9 (/tmp/jl_XL8R4T/bin+0x162bc9) #1 0x7f846f22a1c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 328820b908de8ea1ef79afa8995e302e819163d7) #2 0x7f846f22a28a (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 328820b908de8ea1ef79afa8995e302e819163d7) #3 0x55ed1d1343f4 (/tmp/jl_XL8R4T/bin+0x2b3f4) Address 0x7f846d20002c is located in stack of thread T0 at offset 44 in frame #0 0x55ed1d26baaf (/tmp/jl_XL8R4T/bin+0x162aaf) This frame has 2 object(s): [32, 36) 'i' (line 6) [48, 56) 'a' (line 7) <== Memory access at offset 44 underflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow (/tmp/jl_XL8R4T/bin+0x162bc9) Shadow bytes around the buggy address: 0x7f846d1ffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d1ffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d1ffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d1fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d1fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x7f846d200000: f1 f1 f1 f1 04[f2]00 f3 f3 f3 f3 f3 00 00 00 00 0x7f846d200080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d200100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d200180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d200200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7f846d200280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==11639==ABORTING text/plaincell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dckwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/CBqeh/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbody
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i = 0;
    int a[2];
    a[-1] = 1000000;
    a[2] = -1000000;
    printf("&i = %p\n", &i);
    printf("&a = %p\n", &a);
    printf("i = %d\n", i);
    return EXIT_SUCCESS;
}
persist_js_state¤mimetext/htmllast_run_timestampAڝN63has_pluto_hook_features¬rootassigneecell_id$e3053cb5-186d-4c98-86c7-609be4a7c8dcdepends_on_disabled_cells§runtime#Ipublished_object_keysdepends_on_skipped_cells§errored$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378queued¤logsrunning¦outputbodyV

Exemple avec sanitize

persist_js_state¤mimetext/htmllast_run_timestampAڝ{ihas_pluto_hook_features¬rootassigneecell_id$b3f5afd5-3bcc-44ed-8e35-104a3a7c3378depends_on_disabled_cells§runtime˵published_object_keysdepends_on_skipped_cells§errored$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60queued¤logsrunning¦outputbody
persist_js_state¤mimetext/htmllast_run_timestampAڝ{has_pluto_hook_features¬rootassigneecell_id$ee9648f2-bd69-4bf4-b95b-cc3fc2bf5b60depends_on_disabled_cells§runtimeqpublished_object_keysdepends_on_skipped_cells§errored$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbqueued¤logsrunning¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝ^has_pluto_hook_features¬rootassigneecell_id$10e3b9fb-fe77-4106-a512-74f4d7d0cfbbdepends_on_disabled_cells§runtime(x͵published_object_keysdepends_on_skipped_cells§errored$d50aa7f3-9c15-412e-82c2-f870aab8ffb0queued¤logsrunning¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝ7has_pluto_hook_features¬rootassigneecell_id$d50aa7f3-9c15-412e-82c2-f870aab8ffb0depends_on_disabled_cells§runtimeEǵpublished_object_keysdepends_on_skipped_cells§errored$52ddb3b6-0f88-4596-a480-d4d17489292cqueued¤logsrunning¦outputbodylB

Lors de la correction, nous vérifierons qu'il n'y a pas de fuites de mémoire avec Valgrind

persist_js_state¤mimetext/htmllast_run_timestampAڝ6۷has_pluto_hook_features¬rootassigneecell_id$52ddb3b6-0f88-4596-a480-d4d17489292cdepends_on_disabled_cells§runtime ?ٵpublished_object_keysdepends_on_skipped_cells§errored$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bqueued¤logsrunning¦outputbodyV

Clarifications projet

persist_js_state¤mimetext/htmllast_run_timestampAڝ{ݐhas_pluto_hook_features¬rootassigneecell_id$6764ba72-95ec-4f3b-ac10-4e7e1b2bcf3bdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$5892921c-b019-418c-ba01-3d7a4e4697b3queued¤logsrunning¦outputbody'

On ne partage normalement pas de fichiers binaires (ex : .o) par git car ce n'est pas portable (ex : ce .o ne marche pas sur Mac OS si compilé sur un Raspberry). Lorsque des fichiers auto-générés apparaissent dans la sortie de git status, ajoutez-les dans le .gitignore. Supprimez-les de git avec git rm s'ils ont été ajouté précédemment par accident, ce qui ne devrait pas arriver si git add -p est toujours utilisé au lieu de git add ..

C'est une bonne chose d'écrire des unit tests, mais comme les signatures des fonctions sont libres, nous utiliserons l'interface uniformisée en ligne de commande pour testez votre code. Assurez-vous qu'elle fonctionne comme demandée.

Le Makefile génère un exécutable. Vous pouvez l'utiliser de la façon suivante :

./<nom du fichier> [arguments]
persist_js_state¤mimetext/htmllast_run_timestampAڝ{Fhas_pluto_hook_features¬rootassigneecell_id$5892921c-b019-418c-ba01-3d7a4e4697b3depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$18e1147f-ef60-4368-819b-4e41c1b904dfqueued¤logsrunning¦outputbodyY

The End

persist_js_state¤mimetext/htmllast_run_timestampAڝ{޷has_pluto_hook_features¬rootassigneecell_id$18e1147f-ef60-4368-819b-4e41c1b904dfdepends_on_disabled_cells§runtimed!published_object_keysdepends_on_skipped_cells§errored$9afe0855-162f-4234-8001-610e08e39bb0queued¤logsrunning¦outputbody
persist_js_state¤mimetext/htmllast_run_timestampAڝ{Vhas_pluto_hook_features¬rootassigneecell_id$9afe0855-162f-4234-8001-610e08e39bb0depends_on_disabled_cells§runtime>published_object_keysdepends_on_skipped_cells§errored$7a9a1afc-16a3-11f0-2474-67fc85a76676queued¤logsrunning¦outputbodyVF

LEPL1503/LSINC1503 - Cours 5

O. Bonaventure, B. Legat, M. Baerts

      persist_js_state¤mimetext/htmllast_run_timestampAڝ;,has_pluto_hook_features¬rootassigneecell_id$7a9a1afc-16a3-11f0-2474-67fc85a76676depends_on_disabled_cells§runtimemWpublished_object_keysdepends_on_skipped_cells§errored$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0queued¤logslinemsg١Compiling : `/home/runner/.julia/artifacts/207eb5b8330e24674fe59b50d72f4b3d946219c8/tools/clang -Wno-array-bounds -g /tmp/jl_bIQOXe/main.c -o /tmp/jl_bIQOXe/bin`text/plaincell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0kwargsidMyUtils_6794ab28fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsgRunning : `/tmp/jl_bIQOXe/bin`text/plaincell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0kwargsidMyUtils_0f723ef4fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsg5&i = 0x7ffdfedc3118 &a = 0x7ffdfedc3110 i = -1000000 text/plaincell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0kwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/CBqeh/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbody
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i = 0;
    int a[2];
    a[-1] = 1000000;
    a[2] = -1000000;
    printf("&i = %p\n", &i);
    printf("&a = %p\n", &a);
    printf("i = %d\n", i);
    return EXIT_SUCCESS;
}
persist_js_state¤mimetext/htmllast_run_timestampAڝ;ַhas_pluto_hook_features¬rootassigneecell_id$ff911f08-d9a3-41f3-8e8d-c8e94fecacf0depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$3b928e29-a281-4dc2-9429-41e7d98dad54queued¤logsrunning¦outputbodyV

Exemple sans sanitize

persist_js_state¤mimetext/htmllast_run_timestampAڝ{qhas_pluto_hook_features¬rootassigneecell_id$3b928e29-a281-4dc2-9429-41e7d98dad54depends_on_disabled_cells§runtimeG9published_object_keysdepends_on_skipped_cells§errored$47f92d66-0834-4f8d-9bdf-172c55e93ccequeued¤logsrunning¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝ0}has_pluto_hook_features¬rootassigneecell_id$47f92d66-0834-4f8d-9bdf-172c55e93ccedepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$dfb72971-ccf6-46ec-b686-37e071bd9598queued¤logsrunning¦outputbodyX

Interface par fichiers

persist_js_state¤mimetext/htmllast_run_timestampAڝ{has_pluto_hook_features¬rootassigneecell_id$dfb72971-ccf6-46ec-b686-37e071bd9598depends_on_disabled_cells§runtimeҵpublished_object_keysdepends_on_skipped_cells§errored$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8queued¤logslinemsgٌCompiling : `/home/runner/.julia/artifacts/207eb5b8330e24674fe59b50d72f4b3d946219c8/tools/clang /tmp/jl_hXEhAg/main.c -o /tmp/jl_hXEhAg/bin`text/plaincell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8kwargsidMyUtils_6794ab28fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsg'Running : `valgrind /tmp/jl_hXEhAg/bin`text/plaincell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8kwargsidMyUtils_0f723ef4fileA/home/runner/work/LEPL1503/LEPL1503/Lectures/MyUtils/src/clang.jlgroupclanglevelInfolinemsg8==11631== Memcheck, a memory error detector ==11631== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==11631== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info ==11631== Command: /tmp/jl_hXEhAg/bin ==11631== ==11631== Invalid write of size 4 ==11631== at 0x10915A: f (in /tmp/jl_hXEhAg/bin) ==11631== by 0x109183: main (in /tmp/jl_hXEhAg/bin) ==11631== Address 0x4a79068 is 0 bytes after a block of size 40 alloc'd ==11631== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==11631== by 0x109151: f (in /tmp/jl_hXEhAg/bin) ==11631== by 0x109183: main (in /tmp/jl_hXEhAg/bin) ==11631== ==11631== ==11631== HEAP SUMMARY: ==11631== in use at exit: 40 bytes in 1 blocks ==11631== total heap usage: 1 allocs, 0 frees, 40 bytes allocated ==11631== ==11631== LEAK SUMMARY: ==11631== definitely lost: 40 bytes in 1 blocks ==11631== indirectly lost: 0 bytes in 0 blocks ==11631== possibly lost: 0 bytes in 0 blocks ==11631== still reachable: 0 bytes in 0 blocks ==11631== suppressed: 0 bytes in 0 blocks ==11631== Rerun with --leak-check=full to see details of leaked memory ==11631== ==11631== For lists of detected and suppressed errors, rerun with: -s ==11631== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) text/plaincell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8kwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/CBqeh/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbody
#include <stdlib.h>

void f(void)
{
    int *x = malloc(10 * sizeof(int));
    x[10] = 0; // problem 1: heap block overrun
} // problem 2: memory leak -- x not freed

int main(void)
{
    f();
    return 0;
} // From https://valgrind.org/docs/manual/quick-start.html
persist_js_state¤mimetext/htmllast_run_timestampAڝ6z5has_pluto_hook_features¬rootassigneecell_id$d16d02fb-ad22-4886-aecc-42fc3a9bc2d8depends_on_disabled_cells§runtimeOBpublished_object_keysdepends_on_skipped_cells§errored$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fqueued¤logsrunning¦outputbody>

Debugging

persist_js_state¤mimetext/htmllast_run_timestampAڝ{Vhas_pluto_hook_features¬rootassigneecell_id$9e9a0b57-30ce-4c9c-b0f5-a111f692d13fdepends_on_disabled_cells§runtime@published_object_keysdepends_on_skipped_cells§errored$d87d73d9-d9d8-46e9-9599-0daa7fa95e9cqueued¤logsrunning¦outputbodyn

Chacun doit contribuer sur le Git

persist_js_state¤mimetext/htmllast_run_timestampAڝ{has_pluto_hook_features¬rootassigneecell_id$d87d73d9-d9d8-46e9-9599-0daa7fa95e9cdepends_on_disabled_cells§runtimeN published_object_keysdepends_on_skipped_cells§errored$a843fc18-5290-414a-a5db-dacd4ac88f1dqueued¤logsrunning¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝpehas_pluto_hook_features¬rootassigneecell_id$a843fc18-5290-414a-a5db-dacd4ac88f1ddepends_on_disabled_cells§runtime $+published_object_keysdepends_on_skipped_cells§errored$4790109e-06b0-4518-a95f-ed9ca8b5f595queued¤logsrunning¦outputbodypersist_js_state¤mimetext/plainlast_run_timestampAڝuhas_pluto_hook_features¬rootassigneecell_id$4790109e-06b0-4518-a95f-ed9ca8b5f595depends_on_disabled_cells§runtimePpublished_object_keysdepends_on_skipped_cells§errored$810cdd19-7e3f-4cf4-a337-d9c1244e96cequeued¤logsrunning¦outputbody
persist_js_state¤mimetext/htmllast_run_timestampAڝ{Ihas_pluto_hook_features¬rootassigneecell_id$810cdd19-7e3f-4cf4-a337-d9c1244e96cedepends_on_disabled_cells§runtime uppublished_object_keysdepends_on_skipped_cells§errored©shortpathCours5.jllast_save_timeAڝyin_temp_dir¨metadata