diff --git a/Segfault.md b/Segfault.md new file mode 100644 index 0000000..fa04a3a --- /dev/null +++ b/Segfault.md @@ -0,0 +1,34 @@ +# Segfaults. We hate them... + +## Definiton: +In computing, a segmentation fault (often shortened to segfault) or access violation is a failure condition raised by hardware with memory protection, notifying an operating system (OS) that the software has attempted to access a restricted area of memory (a memory access violation). On standard x86 computers, this is a form of general protection fault. The operating system kernel will, in response, usually perform some corrective action, generally passing the fault on to the offending process by sending the process a signal. Processes can in some cases install a custom signal handler, allowing them to recover on their own, but otherwise the OS default signal handler is used, generally causing abnormal termination of the process (a program crash), and sometimes a core dump. +([Source](https://en.wikipedia.org/wiki/Segmentation_fault)). + +## Note: +This definition was purely for educational purposes, you can stop here if you don't hate Segfaults :nerd_face:. I am writing this with the intention of expressing my hate for this error, that made my hair go white. + +## Why I hate it :rage:: +1. It can be caused from basically everything if you are not paying attention when working with dinamically allocated memory. You didn't free? Segfault. You did free? Maybe Segfault. You allocated bad? Segfault. You allocated in the first place? Your chances of Segfaults are at 90%. +1. It can take time to repair...when a C or C++ program segfaults, the terminal typically spits out just a few unhelpful words: Segmentation fault (core dumped). There is no context, no line number, and no immediate clue as to what went wrong. You are entirely on your own to figure out where the crash happened. Just you and Valgrind... +1. Because segfaults are intimately tied to exactly how a program is laid out in the computer's physical RAM, attempting to debug them can inadvertently change their behavior. +If you add a simple print statement to try and track down where the code is failing, you alter the size of the compiled program and shift its memory layout. Suddenly, the segfault might move to a completely different part of the program, or it might vanish entirely—only to return the moment you remove your debugging code. + +## How do I solve Segfaults? +Well...there could be light after dark after all, your heroes are: +- **Valgrind**: + - Run with: + ```bash + valgrind + ``` +- **GDB**: + 1. First, you have to compile your code with: + ```bash + gcc ... -g ... + ``` + 2. After that, you have to run it with: + ```bash + gdb + ``` + +### So, to end it on a funny note: +![Segfault Meme](https://i.programmerhumor.io/2025/07/39f9ce344066838d5f3d50da0abb33e99369f9f71afa6320a1d34ca6d8b016c5.png) diff --git a/dynamic-linking.ro.md b/dynamic-linking.ro.md index 76a344b..5bdddf4 100644 --- a/dynamic-linking.ro.md +++ b/dynamic-linking.ro.md @@ -186,4 +186,4 @@ num_items: 1 Variabila de mediu `LD_LIBRARY_PATH` pentru loader este echivalentul opțiunii `-L` în comanda de linkare: precizează directoarele în care să fie căutate biblioteci pentru a fi încărcate, respectiv linkate. Folosirea variabilei de mediu `LD_LIBRARY_PATH` este recomandată pentru teste. -Pentru o folosire robustă, există alte mijloace de precizare a căilor de căutare a bibliotecilor partajate, documentate în [pagina de manual a loaderului / linkerului dinamic](https://man7.org/linux/man-pages/man8/ld.so.8.html#DESCRIPTION). +Pentru o folosire robustă, există alte mijloace de precizare a căilor de căutare a bibliotecilor partajate, documentate în (pagina de manual a loaderului / linkerului dinamic)[https://man7.org/linux/man-pages/man8/ld.so.8.html#DESCRIPTION]. diff --git a/helloworld.md b/helloworld.md new file mode 100644 index 0000000..159a94f --- /dev/null +++ b/helloworld.md @@ -0,0 +1,84 @@ +# Helloworld Programs + +![Hello, World!](https://github.com/SerbaC6/workshop-markdown-fork/blob/helloworld/helloworld.png?raw=true) + +We list below Helloworld programs for different programming languages, i.e. programs that print "Hello, World!". The +specified compiler or interpreter is required for each programming languages. + +The table below summarizes the programs: + +| *Language* | *Language (Spec) Site* | *Section* | *Build / Run Toolchain* | *Debian / Ubuntu Packages* | +| :----- | :--------------------: | :-------: | :---------------------: | :------------------------: | +| C | [The Standard - C](https://www.iso-9899.info/wiki/The_Standard) | [C]() | GCC |``build-essential`` | +| C++ | [The Standard - C++](https://isocpp.org/std/the-standard) | [C++]() | GCC / G++ |``build-essential, g++`` | +| Dlang | [D Programming Language: Hpme](https://dlang.org/) | [Dlang]() | GCC / GDC |``build-essential, gdc`` | +| Go | [The Go Programming Language](https://go.dev/) | [Go]() | Go |``golang`` | +| Rust | [Rust Programming Language](https://www.rust-lang.org/) | [Rust]() | Rust(Crate) |``rustlang`` | +|Java | [Java Programming Language](https://docs.oracle.com/javase/8/docs/technotes/guides/language/) | [Java]() | JDK | ``openjdk-17-jdk`` | +|x86_64 assembly | [x86 and amd64 instruction reference](https://www.felixcloutier.com/x86/) | [x86_64]() | Assembly GCC / GAS | ``build-essential`` | +|ARM64 assembly | [Arm A64 Instruction Set Architecture](https://developer.arm.com/documentation/ddi0596/latest/) | [ARM64 Assembly]() | GCC / GAS (AArch64) | ``build-essential``| +|Bash | [Bash Reference Manual](https://www.gnu.org/s/bash/manual/bash.html) | [Bash]() | Bash | ``bash``| +|Python| [Welcome to Python.org](https://www.python.org/)| [Python]() | Python | ``python``| +|Ruby | [Ruby Programming Language](https://www.ruby-lang.org/en/) | [Ruby]() | Ruby |``ruby``| +|PHP | [PHP: Hypertext Preprocessor](https://www.php.net/)| [PHP]() | PHP | ``php`` | +|Perl| [The Perl Programming Language](https://www.perl.org/) | [Perl]() | Perl | ``perl``| +|Lua | [The Programming Language Lua](https://www.lua.org/) | [Lua]() | Lua | ``lua``| + + + +# C +```C +#include +int main(void) +{ +puts("Hello, World!"); +return 0; + +} +``` + +Build with: +```bash +gcc -Wall -o helloworld helloworld.c +``` +Run with: +```bash +./helloworld +``` + +# C++ +```C++ +#include +int main() +{ +std::cout << "Hello, World!" << std::endl; +return 0; +} +``` + +Build with: +```bash +g++ -Wall -o helloworld helloworld.cpp +``` + +Run with: +```bash +./helloworld +``` + +# Dlang +```dlang +import std.stdio; +void main() +{ +writeln("Hello, World!"); +} +``` +Build with: +```bash +gdc -Wall -o helloworld helloworld.cpp +``` +Run with: +```bash +./helloworld +``` \ No newline at end of file