Skip to content
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

Missing response body on Linux using -d:danger --passC:-flto #112

Open
tdely opened this issue Dec 19, 2023 · 2 comments
Open

Missing response body on Linux using -d:danger --passC:-flto #112

tdely opened this issue Dec 19, 2023 · 2 comments

Comments

@tdely
Copy link

tdely commented Dec 19, 2023

On Linux when compiled with -d:danger --passC:-flto running the following example code will crash with Error uncompressing response [PuppyError]:

import puppy

for i in 1..1:
  let resp = fetch("http://neverssl.com")

Removing the for loop avoids the issue, as does not using either -d:danger or --passC:-flto.
For some reason bodyWrap does not get set properly at line 76 in src/puppy/platforms/linux/platform.nim resulting in an empty string.

@guzba
Copy link
Collaborator

guzba commented Feb 2, 2024

What Nim version were you compiling with?

My guess is Nim 1.x where threads are disabled by default. The issue is, when using libcurl, a callback proc is provided to libcurl. This callback is what fills bodyWrap with data as it is received. Since this callback looks like it is not called in any Nim source code, it is probably being removed when -flto is used.

This could probably be fixed when compiling including --threads:on for Nim 1.x but that is just a hunch. Passing -f:lto is not without complication as described in the lengthy paragraphs here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flto

@tdely
Copy link
Author

tdely commented Feb 2, 2024

The Nim version was 2.0.2, I should have included that in the original post. Unfortunately not as easy as --threads:on! Thank you for the explanation on how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants