<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Hacker News: acidx</title><link>https://news.ycombinator.com/user?id=acidx</link><description>Hacker News RSS</description><docs>https://hnrss.org/</docs><generator>hnrss v2.1.1</generator><lastBuildDate>Wed, 08 Apr 2026 03:48:44 +0000</lastBuildDate><atom:link href="https://hnrss.org/user?id=acidx" rel="self" type="application/rss+xml"></atom:link><item><title><![CDATA[New comment by acidx in "Love C, hate C: Web framework memory problems"]]></title><description><![CDATA[
<p>Yes! The JSON library I wrote for the Zephyr RTOS does this.  Say, for instance, you have the following struct:<p><pre><code>    struct SomeStruct {
        char *some_string;
        int some_number;
    };
</code></pre>
You would need to declare a descriptor, linking each field to how it's spelled in the JSON (e.g. the some_string member could be "some-string" in the JSON), the byte offset from the beginning of the struct where the field is (using the offsetof() macro), and the type.<p>The parser is then able to go through the JSON, and initialize the struct directly, as if you had reflection in the language.  It'll validate the types as well.  All this without having to allocate a node type, perform copies, or things like that.<p>This approach has its limitations, but it's pretty efficient -- and safe!<p>Someone wrote a nice blog post about (and even a video) it a while back: <a href="https://blog.golioth.io/how-to-parse-json-data-in-zephyr/" rel="nofollow">https://blog.golioth.io/how-to-parse-json-data-in-zephyr/</a><p>The opposite is true, too -- you can use the same descriptor to serialize a struct back to JSON.<p>I've been maintaining it outside Zephyr for a while, although with different constraints (I'm not using it for an embedded system where memory is golden): <a href="https://github.com/lpereira/lwan/blob/master/src/samples/techempower/json.c" rel="nofollow">https://github.com/lpereira/lwan/blob/master/src/samples/tec...</a></p>
]]></description><pubDate>Sat, 11 Oct 2025 18:15:23 +0000</pubDate><link>https://news.ycombinator.com/item?id=45551339</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45551339</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45551339</guid></item><item><title><![CDATA[New comment by acidx in "Love C, hate C: Web framework memory problems"]]></title><description><![CDATA[
<p>The Linux man page (<a href="https://man7.org/linux/man-pages/man3/atoi.3.html#VERSIONS" rel="nofollow">https://man7.org/linux/man-pages/man3/atoi.3.html#VERSIONS</a>) says that POSIX.1 leaves it unspecified. As you found out, it's really something that should be avoided as much as possible, because pretty much everywhere disagrees how it should behave, especially if you value portability.<p>sscanf() is not a good replacement either! It's better to use strtol() instead.  Either do what Lwan does (<a href="https://github.com/lpereira/lwan/blob/master/src/lib/lwan-config.c#L156-L174" rel="nofollow">https://github.com/lpereira/lwan/blob/master/src/lib/lwan-co...</a>), or look (<a href="https://cvsweb.openbsd.org/src/lib/libc/stdlib/strtonum.c?rev=1.8&content-type=text/x-cvsweb-markup" rel="nofollow">https://cvsweb.openbsd.org/src/lib/libc/stdlib/strtonum.c?re...</a>) at how OpenBSD implemented strtonum(3).<p>For instance, if you try to parse a number that's preceded by a lot of spaces, sscanf() will take a long time going through it.  I've been hit by that when fuzzing Lwan.<p>Even cURL is avoiding sscanf(): <a href="https://daniel.haxx.se/blog/2025/04/07/writing-c-for-curl/" rel="nofollow">https://daniel.haxx.se/blog/2025/04/07/writing-c-for-curl/</a></p>
]]></description><pubDate>Sat, 11 Oct 2025 01:19:03 +0000</pubDate><link>https://news.ycombinator.com/item?id=45545652</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45545652</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45545652</guid></item><item><title><![CDATA[New comment by acidx in "Love C, hate C: Web framework memory problems"]]></title><description><![CDATA[
<p>One thing to note, too, is that `atoi()` should be avoided as much as possible. On error (parse error, overflow, etc), it has an unspecified return value (!), although most libcs will return 0, which can be just as bad in some scenarios.<p>Also not mentioned, is that atoi() can return a negative number -- which is then passed to malloc(), that takes a size_t, which is unsigned... which will make it become a very large number if a negative number is passed as its argument.<p>It's better to use strtol(), but even that is a bit tricky to use, because it doesn't touch errno when there's no error but you need to check errno to know if things like overflow happened, so you need to set errno to 0 before calling the function. The man page explains how to use it properly.<p>I think it would be a very interesting exercise for that web framework author to make its HTTP request parser go through a fuzz-tester; clang comes with one that's quite good and easy to use (<a href="https://llvm.org/docs/LibFuzzer.html" rel="nofollow">https://llvm.org/docs/LibFuzzer.html</a>), especially if used alongside address sanitizer or the undefined behavior sanitizer.  Errors like the one I mentioned will most likely be found by a fuzzer really quickly. :)</p>
]]></description><pubDate>Sat, 11 Oct 2025 00:11:26 +0000</pubDate><link>https://news.ycombinator.com/item?id=45545217</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45545217</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45545217</guid></item><item><title><![CDATA[New comment by acidx in "Go has added Valgrind support"]]></title><description><![CDATA[
<p>Programs running under any Valgrind tool will be executed using a CPU emulator, making it quite a bit slower than, say, running the instrumented binaries as required by sanitizers; it's often an order of magnitude slower, but could be very well be close to two orders of magnitude slower in some cases. This also means that it just can't be attached to any running program, because, well, it's emulating a whole CPU to track everything it can.<p>(Valgrind using a CPU emulator allows for a lot of interesting things, such as also emulating cache behavior and whatnot; it may be slow and have other drawbacks -- it has to be updated every time the instruction set adds a new instruction for instance -- but it's able to do things that aren't usually possible otherwise precisely because it has a CPU emulator!)</p>
]]></description><pubDate>Tue, 23 Sep 2025 23:01:58 +0000</pubDate><link>https://news.ycombinator.com/item?id=45353933</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45353933</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45353933</guid></item><item><title><![CDATA[New comment by acidx in "Go has added Valgrind support"]]></title><description><![CDATA[
<p>Go has had its own version of msan and asan for years at this point.</p>
]]></description><pubDate>Tue, 23 Sep 2025 17:13:39 +0000</pubDate><link>https://news.ycombinator.com/item?id=45350014</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45350014</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45350014</guid></item><item><title><![CDATA[New comment by acidx in "Go has added Valgrind support"]]></title><description><![CDATA[
<p>I wrote the Lwan web server, which similarly to Go, has its own scheduler and makes use of stackful coroutines.  I have spent quite a bit of time Valgrinding it after adding the necessary instrumentation to not make Valgrind freak out due to the stack pointer changing like crazy.  Despite a lot of Valgrind's limitations due to the way it works, it has been instrumental to finding some subtle concurrency issues in the scheduler and vicinity.<p>From a quick glance, it seems that Go is now registering the stacks and emitting stack change commands on every goroutine context switch.  This is most likely enough to make Valgrind happy with Go's scheduler.</p>
]]></description><pubDate>Tue, 23 Sep 2025 17:12:03 +0000</pubDate><link>https://news.ycombinator.com/item?id=45349988</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45349988</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45349988</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: I built a minimal Forth-like stack interpreter library in C"]]></title><description><![CDATA[
<p>I recently wrote one, in C, using tail calls to implement dispatch with CPS: <a href="https://tia.mat.br/posts/2025/08/30/forth-haiku.html" rel="nofollow">https://tia.mat.br/posts/2025/08/30/forth-haiku.html</a><p>It's already pretty efficient but I'm working on it to make it even more efficient so I can use it as some sort of primitive fragment shader for an art project.  This Forth variant is intended to execute Forth Haikus, as defined by the Forth Salon website.</p>
]]></description><pubDate>Thu, 11 Sep 2025 15:39:48 +0000</pubDate><link>https://news.ycombinator.com/item?id=45212891</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=45212891</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=45212891</guid></item><item><title><![CDATA[New comment by acidx in "Implementing a Forth"]]></title><description><![CDATA[
<p>I recently implemented a Forth, compatible with the Forth Haiku dialect used by <a href="https://forthsalon.appspot.com/" rel="nofollow">https://forthsalon.appspot.com/</a> -- it uses a tail call/continuation-passing dispatching method, and performs some rudimentary optimizations.  At some point it also spit out some C but I decided to give this feature the axe until it has a better infrastructure for optimizations and codegen.<p>The idea is to use it to drive an LED matrix and have a simple web UI to develop "fragment shaders" in Forth.  It's developed as part of the Lwan project, although currently it generates GIF files on the fly rather than drive a LED matrix.<p>The source code is here for those that want to play with it: <a href="https://github.com/lpereira/lwan/tree/master/src/samples/forthsalon">https://github.com/lpereira/lwan/tree/master/src/samples/for...</a></p>
]]></description><pubDate>Tue, 03 Jun 2025 18:35:51 +0000</pubDate><link>https://news.ycombinator.com/item?id=44173156</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=44173156</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=44173156</guid></item><item><title><![CDATA[New comment by acidx in "A map of torii around the world"]]></title><description><![CDATA[
<p>There's another small one in Campinas, near the Nipo-Brazilian Institute: <a href="https://viajantesemfim.com.br/rua-camargo-paes-um-pedacinho-do-japao-em-campinas/" rel="nofollow">https://viajantesemfim.com.br/rua-camargo-paes-um-pedacinho-...</a> (or on GMaps: <a href="https://maps.app.goo.gl/P17sBzkNG3Gk4frq5" rel="nofollow">https://maps.app.goo.gl/P17sBzkNG3Gk4frq5</a>)<p>I'm sure there are many, many more throughout the country, especially in the states of São Paulo and Paraná.</p>
]]></description><pubDate>Sun, 23 Feb 2025 08:22:48 +0000</pubDate><link>https://news.ycombinator.com/item?id=43147721</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=43147721</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=43147721</guid></item><item><title><![CDATA[New comment by acidx in "New York, Ukraine"]]></title><description><![CDATA[
<p>Also in Brazil: <a href="https://en.wikipedia.org/wiki/Nova_Iorque" rel="nofollow">https://en.wikipedia.org/wiki/Nova_Iorque</a></p>
]]></description><pubDate>Fri, 19 Jul 2024 22:34:19 +0000</pubDate><link>https://news.ycombinator.com/item?id=41012132</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=41012132</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=41012132</guid></item><item><title><![CDATA[New comment by acidx in "Tetris Font (2020)"]]></title><description><![CDATA[
<p>Thank you!</p>
]]></description><pubDate>Fri, 21 Jun 2024 23:26:26 +0000</pubDate><link>https://news.ycombinator.com/item?id=40754900</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=40754900</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=40754900</guid></item><item><title><![CDATA[New comment by acidx in "Tetris Font (2020)"]]></title><description><![CDATA[
<p>Reminds me of this sample from the Lwan project: <a href="https://time.lwan.ws/blocks" rel="nofollow">https://time.lwan.ws/blocks</a> -- where the clock is rendered on the server, and new frames are sent to the client using chunked encoding.</p>
]]></description><pubDate>Thu, 20 Jun 2024 15:00:53 +0000</pubDate><link>https://news.ycombinator.com/item?id=40739494</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=40739494</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=40739494</guid></item><item><title><![CDATA[New comment by acidx in "Starting emails with "BEGIN PGP MESSAGE" will fool the filter"]]></title><description><![CDATA[
<p>Details are hazy as this was a long time ago, but at some point you could make parts of messages not render in Outlook and Outlook Express by writing "begin  something" (two spaces after "begin") by itself in a single line.  Outlook would thing that it was the start of an uuencoded block and not render anything after that.<p>I remember annoying friends in a mailing list by quoting emails with "begin  quote from Person Name:" :)</p>
]]></description><pubDate>Thu, 16 May 2024 02:00:08 +0000</pubDate><link>https://news.ycombinator.com/item?id=40374510</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=40374510</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=40374510</guid></item><item><title><![CDATA[New comment by acidx in "Fast linked lists"]]></title><description><![CDATA[
<p>This is roughly what my JSON parser does. It does type-checking, albeit without using JSON-schema, but an object descriptor that you have to define to parse and generate JSON.<p>It's been developed for embedded systems (it was written originally for a NATS implementation in the Zephyr RTOS), so it's a bit limited and there's no easy way to know where some parsing/type validation error happened, but the information is there if one wants to obtain it: <a href="https://github.com/lpereira/lwan/blob/master/src/samples/techempower/json.c">https://github.com/lpereira/lwan/blob/master/src/samples/tec...</a></p>
]]></description><pubDate>Tue, 14 May 2024 22:07:31 +0000</pubDate><link>https://news.ycombinator.com/item?id=40360700</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=40360700</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=40360700</guid></item><item><title><![CDATA[How async/await works in the Lwan web server]]></title><description><![CDATA[
<p>Article URL: <a href="https://tia.mat.br/posts/2024/02/29/async-await-in-lwan.html">https://tia.mat.br/posts/2024/02/29/async-await-in-lwan.html</a></p>
<p>Comments URL: <a href="https://news.ycombinator.com/item?id=39671071">https://news.ycombinator.com/item?id=39671071</a></p>
<p>Points: 1</p>
<p># Comments: 0</p>
]]></description><pubDate>Mon, 11 Mar 2024 17:33:24 +0000</pubDate><link>https://tia.mat.br/posts/2024/02/29/async-await-in-lwan.html</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=39671071</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=39671071</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: Host a Website in the URL"]]></title><description><![CDATA[
<p>Yes, that's the library!  It's something I've been slow cooking for over 10 years at this point. :)</p>
]]></description><pubDate>Mon, 11 Sep 2023 16:49:14 +0000</pubDate><link>https://news.ycombinator.com/item?id=37469982</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=37469982</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=37469982</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: Host a Website in the URL"]]></title><description><![CDATA[
<p>It's collected after 15min, give or take. The hash isn't random, it's the SHA-1 hash of the base64-encoded data, so it's predictable -- if something keeps accessing the base-64 encoded URL, the /s/... URL won't vanish.<p>I tried making it more strict (by checking the Sec-Fetch-Site and Sec-Fetch-Dest headers), but not all browsers send that.</p>
]]></description><pubDate>Thu, 07 Sep 2023 04:38:49 +0000</pubDate><link>https://news.ycombinator.com/item?id=37414821</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=37414821</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=37414821</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: Host a Website in the URL"]]></title><description><![CDATA[
<p>On the client.<p>Data is already stored in the ZIP file deflated, so I can just send whatever is inside the ZIP file back to the client if they accept that encoding (which is pretty much always the case, given how ubiquitous deflate is).<p>The server parses the ZIP file and stores that information in a hash table for quicker lookup but it's otherwise not decompressing anything.  This hash table is kept for a few minutes to avoid having to decode the base64-encoded data and parse the ZIP file for every request.</p>
]]></description><pubDate>Wed, 06 Sep 2023 22:34:25 +0000</pubDate><link>https://news.ycombinator.com/item?id=37412346</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=37412346</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=37412346</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: Host a Website in the URL"]]></title><description><![CDATA[
<p>I love this!</p>
]]></description><pubDate>Wed, 06 Sep 2023 21:47:02 +0000</pubDate><link>https://news.ycombinator.com/item?id=37411826</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=37411826</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=37411826</guid></item><item><title><![CDATA[New comment by acidx in "Show HN: Host a Website in the URL"]]></title><description><![CDATA[
<p>Then it would require JavaScript and wouldn't be a nice demonstration for my web server library. :)</p>
]]></description><pubDate>Wed, 06 Sep 2023 21:44:55 +0000</pubDate><link>https://news.ycombinator.com/item?id=37411807</link><dc:creator>acidx</dc:creator><comments>https://news.ycombinator.com/item?id=37411807</comments><guid isPermaLink="false">https://news.ycombinator.com/item?id=37411807</guid></item></channel></rss>