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

uwsgi segmentation fault #278

Open
g3ngr33n opened this issue Nov 9, 2019 · 4 comments
Open

uwsgi segmentation fault #278

g3ngr33n opened this issue Nov 9, 2019 · 4 comments

Comments

@g3ngr33n
Copy link
Contributor

g3ngr33n commented Nov 9, 2019

*** uWSGI building plugins ***
*** building plugin: http ***
/var/tmp/portage/www-servers/uwsgi-2.0.17/temp/environment: line 5151: 3686 Segmentation fault python uwsgiconfig.py --build gentoo

  • ERROR: www-servers/uwsgi-2.0.17::gentoo failed (compile phase):
  • building uwsgi failed
  • Call stack:
  • ebuild.sh, line 125:  Called src_compile
    
  • environment, line 5153: Called die
  • The specific snippet of code:
  •   python uwsgiconfig.py --build gentoo || die "building uwsgi failed";
    

[322807.815182] python3.6[30811]: segfault at 699c2bc83010 ip 0000699c2c5841d5 sp 00007ae490ce5170 error 4 in libc.so[699c2c57b000+5f000]
[322807.815186] Code: 75 28 5b 31 c0 5d 41 5c c3 0f 1f 40 00 4c 89 e2 48 89 ef e8 6d 4b 04 00 85 c0 75 0a 48 8b 03 42 80 3c 20 3d 74 0f 48 83 c3 08 <48> 8b 33 48 85 f6 75 db eb ce 90 4a 8d 44 20 01 5b 5d 41 5c c3 66

It however work when gentoo is removed from python uwsgiconfig.py --build gentoo

Not sure if musl is the problem here

Thanks,

@anarchpenguin
Copy link
Contributor

https://git.alpinelinux.org/aports/tree/main/uwsgi/musl-fix-python.patch if you would test with the following patch thanks.

@g3ngr33n
Copy link
Contributor Author

Did not get any luck :
http://dpaste.com/0N7EBQR

@anarchpenguin
Copy link
Contributor

[66251.846980] python3.6[19145]: segfault at 7fa5d78cd010 ip 00007fa5d80e6eb2 sp 00007fa5d7934d70 error 4 in libsandbox.so[7fa5d80e5000+a000]

I am gonna dig into it and see what I can figure out.

@g3ngr33n
Copy link
Contributor Author

Alright thanks, take your time as I'm not at all in the rush for this

For the meantime :

I replaced strncpy to memcpy for somes files, build pass but throw some warning

http://dpaste.com/3AVZYN3

Patch I applied

--- a/core/notify.c
+++ b/core/notify.c
@@ -56,7 +56,7 @@
 	sd_sun = uwsgi_malloc(sizeof(struct sockaddr_un));
 	memset(sd_sun, 0, sizeof(struct sockaddr_un));
 	sd_sun->sun_family = AF_UNIX;
-	strncpy(sd_sun->sun_path, systemd_socket, UMIN(len, sizeof(sd_sun->sun_path)));
+	memcpy(sd_sun->sun_path, systemd_socket, UMIN(len, sizeof(sd_sun->sun_path)));
 	if (sd_sun->sun_path[0] == '@')
 		sd_sun->sun_path[0] = 0;
 
--- a/core/signal.c
+++ b/core/signal.c
@@ -123,7 +123,7 @@
 		return -1;
 	}
 
-	strncpy(use->receiver, receiver, strlen(receiver) + 1);
+	memcpy(use->receiver, receiver, strlen(receiver) + 1);
 	use->handler = handler;
 	use->modifier1 = modifier1;
 	use->wid = uwsgi.mywid;

--- a/core/utils.c
+++ b/core/utils.c
@@ -3426,7 +3426,7 @@
 
 	wi->modifier1 = modifier1;
 	wi->mountpoint_len = mountpoint_len < 0xff ? mountpoint_len : (0xff - 1);
-	strncpy(wi->mountpoint, mountpoint, wi->mountpoint_len);
+	memcpy(wi->mountpoint, mountpoint, wi->mountpoint_len);
 	wi->interpreter = interpreter;
 	wi->callable = callable;
 
--- a/core/plugins.c
+++ b/core/plugins.c
@@ -180,7 +180,7 @@
 			if ((linkpath_size = readlink(plugin_abs_path, linkpath_buf, 1023)) > 0) {
 				do {
 					linkpath_buf[linkpath_size] = '\0';
-					strncpy(linkpath, linkpath_buf, linkpath_size + 1);
+					memcpy(linkpath, linkpath_buf, linkpath_size + 1);
 				} while ((linkpath_size = readlink(linkpath, linkpath_buf, 1023)) > 0);
 #ifdef UWSGI_DEBUG
 				uwsgi_log("%s\n", linkpath);

--- a/core/mule.c
+++ b/core/mule.c
@@ -452,7 +452,7 @@
 			mules_list[0] = 0;
 			mules_list++;
 
-			strncpy(uwsgi.farms[i].name, farm_value, 0xff);
+			memcpy(uwsgi.farms[i].name, farm_value, 0xff);
 			
 
 			// create the socket pip

What do you think ?

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