| 1 | Title: Debugging |
| 2 | |
| 3 | If you experience a crash with Libdex, usually it is a programming error in your application. |
| 4 | Here are a few common things to look for. |
| 5 | |
| 6 | # Improper Ownership Transfer |
| 7 | |
| 8 | Many if not most APIs in Libdex will transfer ownership as part of the constructor or methods. |
| 9 | That typically plays nicely with chaining futures together when writing code in C. |
| 10 | |
| 11 | Be aware that if you are doing something with a future like [[email protected]] that ownership of the future is transferred to the method. |
| 12 | The same goes for methods like [[email protected]]. |
| 13 | |
| 14 | The `dex_future_allv()` and similar array-of-future functions do not transfer full because they are more likely to be used by language bindings. |
| 15 | |
| 16 | # Performance |
| 17 | |
| 18 | If libdex was built with `-Dsysprof=true` then Libdex may emit marks representing the lifetimes of [[email protected]]. |
| 19 | You can run `sysprof-cli capture.syscap -- ./program` to record your application. |
| 20 | Open the capture with the Sysprof application to view future lifetimes in the Marks section. |
| 21 | |
| 22 | # Future Names |
| 23 | |
| 24 | When compiling with GCC, Libdex headers automatically wrap common future, |
| 25 | promise, and fiber constructors to set static debug names such as source |
| 26 | locations or fiber function names. |
| 27 | These names are useful while debugging and when viewing Sysprof marks, but the |
| 28 | associated strings will be included in the consuming program. |
| 29 | |
| 30 | Applications that do not want those strings included in their binary can define |
| 31 | `DEX_DISABLE_STATIC_NAME_MACROS` before including Libdex headers, or pass |
| 32 | `-DDEX_DISABLE_STATIC_NAME_MACROS` in their compiler flags. |
| 33 | |
| 34 | # Stack Overflow on Fibers |
| 35 | |
| 36 | The default fiber size is rather small since we are trying to make it convenient for applications to use a large number of fibers. |
| 37 | Some work done on fibers may expect to have larger stack space. |
| 38 | If you are doing work that is expected to call into graphics drivers (OpenGL, Vulkan), image codecs (Rsvg, JXL), or multimedia codecs (GStreamer) you may want to use a larger fiber size than the default (currently 128 kB). |