lithium icon indicating copy to clipboard operation
lithium copied to clipboard

Segmentation Fault: 11 for static file over 100KB?

Open harishletsgo opened this issue 4 years ago • 4 comments

I have looked to the extent limited by my knowledge. But does anyone know why I get a segfault 11 when I try to access a file larger than 100KB? Perhaps with two extensions like scripts.bundle.js or widgets.min.css ?

Here is my code snippet

int main(int, char**) {

	li::http_api api;

	api.get("/{{path...}}") = [&](li::http_request& request, li::http_response& response){
			response.write("hey it works");
		};

	api.add_subapi("/assets", li::serve_directory("./static/assets"));


	li::http_serve(api, 8080);
}

harishletsgo avatar Apr 17 '21 04:04 harishletsgo

File size should not be a problem as long as mmap accepts it. Probably a bug in extension handling. I'll check that. Thanks for the report.

matt-42 avatar Apr 21 '21 22:04 matt-42

@matt-42 Awesome project otherwise. I learnt a lot by just glancing through the library. There is absolutely no barriers to entry for anyone to kickstart using Lithium in their projects.

Also, the bug appears on MacOS Big Sur with the following compiler

clang version 11.1.0
Target: x86_64-apple-darwin20.3.0

harishletsgo avatar Apr 22 '21 06:04 harishletsgo

Hi @harishperfect , Thanks for the feedback ! . It was probably a problem with files changing size while the server was running. I revamped the file serving code so there should not be any problems anymore. You can update to the last version of master.

matt-42 avatar Jun 01 '21 09:06 matt-42

@harishperfect actually just wait a bit before I merge the windows support into master (the fix is not in master yet). It will be done later this week.

matt-42 avatar Jun 02 '21 08:06 matt-42