-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault on musl when set big buffer size #108
Comments
The problem is obvious: Line 524 in 4bba916
Line 564 in 4bba916
As such the code overflows the stack. The difference between musl and glibc for this test is that the default thread stack size is smaller on musl: https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread-stack-size The solution should be to get rid of the VLA and instead to dynamically allocate the memory. |
@mixi Thanks. this explains why I get segmentation fault when the buffer size is greater than 128K (or less when I use
So the dirty fix for me would be
I wonder, will that also benefit glibc users that reduces memory usage? I don't have C knowledge, maybe you or someone else else could provide a proper fix like this? -- |
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.
The disadvantage is that you are only moving the problem to a different point. It will still crash if you pass
The same problem exists for glibc, just with a larger buffer size. I was able to reproduce the same error there with 16MB of buffer. My fix also does not save memory (it actually uses more memory, especially on glibc where it now needs to allocate the buffer in addition to their huge thread stack), but that could be mitigated by using |
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.
* Deduplicate the cleanup in handle_connection() * Remove the VLA from handle_connection() 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. * Remove the superfluous call to pthread_exit Returning from the start function of a thread is specified to implicitly call pthread_exit(). * Request a reasonably small thread stack This somewhat mitigates the problem that now the buffer is allocated in addition to the already allocated thread stack. Co-authored-by: Johannes Nixdorf <[email protected]>
* Deduplicate the cleanup in handle_connection() * Remove the VLA from handle_connection() 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. * Remove the superfluous call to pthread_exit Returning from the start function of a thread is specified to implicitly call pthread_exit(). * Request a reasonably small thread stack This somewhat mitigates the problem that now the buffer is allocated in addition to the already allocated thread stack. Co-authored-by: Johannes Nixdorf <[email protected]>
* Deduplicate the cleanup in handle_connection() * Remove the VLA from handle_connection() 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. * Remove the superfluous call to pthread_exit Returning from the start function of a thread is specified to implicitly call pthread_exit(). * Request a reasonably small thread stack This somewhat mitigates the problem that now the buffer is allocated in addition to the already allocated thread stack. Co-authored-by: Johannes Nixdorf <[email protected]>
* Deduplicate the cleanup in handle_connection() * Remove the VLA from handle_connection() 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. * Remove the superfluous call to pthread_exit Returning from the start function of a thread is specified to implicitly call pthread_exit(). * Request a reasonably small thread stack This somewhat mitigates the problem that now the buffer is allocated in addition to the already allocated thread stack. Co-authored-by: Johannes Nixdorf <[email protected]>
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.
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.
fiche -B 262144
gives me Segmentation fault while receiving the first upload on Void Linux musl, it works fine on Void Linux glibc so this issue is probably musl only.gdb debug log
fiche/fiche.c
Line 565 in 4bba916
The text was updated successfully, but these errors were encountered: