Remove the VLA from handle_connection()#109
Conversation
|
I also now implemented the memory savings on glibc by requesting a reasonably small thread stack as proposed in #108. |
|
it only receives 8 bytes on f3c7a29 (tested on musl), no matter if or it's still wip? @ me when you need me to test it. |
This fixes a segfault on musl libc with reasonable sized buffers, as musl's default thread stack size is quite small (128k since 1.1.21). A similar bug exists on glibc with large enough buffers (reproducable with e.g. 16MB on my test system). This commit fixes solusipse#108.
Returning from the start function of a thread is specified to implicitly call pthread_exit().
|
@dashezup: That was me missing that |
|
Nice 👍 , I've tested fcfcff9 on musl, it works properly, I can upload very huge text (like 1G, probably memory was full and can't add more in that case) |
| // Cleanup | ||
| free(c); | ||
| free(slug); | ||
| close(c->socket); |
There was a problem hiding this comment.
NOTE: This was broken before moving the cleanup to the exit label because it called free(c) before dereferencing c.
This somewhat mitigates the problem that now the buffer is allocated in addition to the already allocated thread stack.
|
That was me changing the 16k of requested thread stack to the musl default of 128k. That should probably be safer and still less than the glibc default. |
This fixes a segfault on musl libc with reasonable sized buffers, as
musl's default thread stack size is quite small (128k since 1.1.21).
A similar bug exists on glibc with large enough buffers (reproducable
with e.g. 16MB on my test system).
This fixes #108.