-
Notifications
You must be signed in to change notification settings - Fork 417
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
最后的大作业错误提示:段错误(核心已转存) #33
Comments
有同学遇到相同问题吗,在那句 strncpy(httpRequest->method, start, space - start); 这句话出错了,网上说是一般是内存地址超了,但是感觉逻辑没有错误,希望老师可以指正一下。 |
你的test数据是什么?测试环境是什么? 我先试着重现一下 |
老师您好,非常高兴得到您的回复。我在Ubuntu18.04和Ubuntu20.04系统上都编译了代码。编译代码和启动服务均正常,当在浏览器中中输入127.0.01:43211/ 这条url后发生这个错误提醒,这个好像是内存访问的问题。 |
老师您好,我用的就是您公布的开源代码,不知道您那里现在运行情况如何。 |
我的环境 16.04.6 LTS (GNU/Linux 4.4.0-184-generic x86_64),跑起来正常的。你可以试着debug下。 |
老师您好,经过您的提醒,我刚刚才Ubuntu16.04上重新测试了程序,发现不会出现该错误,没想到系统环境对程序有很大的影响啊。。。,还需努力,谢谢您的指正。 |
您好,我在Ubuntu20.04上运行也遇到同样的问题,想请教一下您知道为什么在Ubuntu18.04和20.04上运行会报错吗 |
不知道,段错误是c++里比较难找的错误,应该是内存方面的问题。 |
|
debug编译然后gdb挂上去看一下就知道了 |
我也在Ubuntu20.04上遇到段错误,老师和兄弟们是怎么解决的? |
段错误的话把涉及到memmem函数的部分全部加上头文件string.h和 #define _GNU_SOURCE就可以了,分别有lib/http_server.c lib/buffer.c chap34/http_server01.c 在wsl ubantu20.04上面有效 |
ubuntu@VM-16-17-ubuntu:~/code/yolanda-master/build/bin$ ./http_server01
[msg] set epoll as dispatcher, main thread
[msg] add channel fd == 5, main thread
[msg] set epoll as dispatcher, Thread-1
[msg] add channel fd == 9, Thread-1
[msg] event loop thread init and signal, Thread-1
[msg] event loop run, Thread-1
[msg] event loop thread started, Thread-1
[msg] set epoll as dispatcher, Thread-2
[msg] add channel fd == 12, Thread-2
[msg] event loop thread init and signal, Thread-2
[msg] event loop run, Thread-2
[msg] event loop thread started, Thread-2
[msg] add channel fd == 6, main thread
[msg] event loop run, main thread
[msg] epoll_wait wakeup, main thread
[msg] get message channel fd==6 for read, main thread
[msg] activate channel fd == 6, revents=2, main thread
[msg] new connection established, socket == 13
[msg] connection completed
[msg] epoll_wait wakeup, Thread-1
[msg] get message channel fd==9 for read, Thread-1
[msg] activate channel fd == 9, revents=2, Thread-1
[msg] wakeup, Thread-1
[msg] add channel fd == 13, Thread-1
[msg] epoll_wait wakeup, main thread
[msg] get message channel fd==6 for read, main thread
[msg] activate channel fd == 6, revents=2, main thread
[msg] new connection established, socket == 14
[msg] connection completed
[msg] epoll_wait wakeup, Thread-2
[msg] get message channel fd==12 for read, Thread-2
[msg] activate channel fd == 12, revents=2, Thread-2
[msg] wakeup, Thread-2
[msg] add channel fd == 14, Thread-2
[msg] epoll_wait wakeup, Thread-1
[msg] get message channel fd==13 for read, Thread-1
[msg] activate channel fd == 13, revents=2, Thread-1
[msg] get message from tcp connection connection-13
Segmentation fault (core dumped)
后面通过print定位到这句话出错:
The text was updated successfully, but these errors were encountered: