Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #157024
| From | Lev Lazinskiy <lev@levlaz.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Segment fault ../sysdeps/i386/i686/multiarch/strcpy-sse2.S |
| Date | 2015-08-29 09:20 +0200 |
| Message-ID | <q2IAG-3ek-1@gated-at.bofh.it> (permalink) |
| References | <q2IAG-3ek-3@gated-at.bofh.it> <q2Ihj-2Cx-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Sat, 2015-08-29 at 08:54 +0200, Dan Richard wrote:
> My Debian is with kernel 4.0.0-2-rt-686-pae, and gcc (Debian 4.9.2
> -10) 4.9.2.
>
> I have a program where it uses strcpy, but when executing
> (compilation successfully), it throws segment fault. Debugging with
> gdb, it shows that it goes worng in strcpy function.
>
> _strcpy_sse2 () at ../sysdeps/i386/i686/multiarch/strcpy-sse2.S:2099
> 2099 ../sysdeps/i386/i686/multiarch/strcpy-sse2.S: No such file or
> directory.
>
> I wrote a simple program, it also throws segment fault.
>
> #include <string.h>
> #include <stdio.h>
> int main(int argc, char **argv)
> {
> char *str;
> strcpy(str, "hello");
> printf("say %s\n", str);
> return 0;
> }
>
> How can I fix this problem?
>
> Thanks
>
Hi,
You are failing to allocate memory. This sample program should look
something like this:
#include <string.h>
#include <stdio.h>
#include <malloc.h>
int main(int argc, char **argv)
{
char *str;
str = malloc (5);
strcpy(str, "hello");
printf("say %s\n", str);
free(str);
return 0;
}
Best,
Lev
Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Segment fault ../sysdeps/i386/i686/multiarch/strcpy-sse2.S Lev Lazinskiy <lev@levlaz.org> - 2015-08-29 09:20 +0200 Re: Segment fault ../sysdeps/i386/i686/multiarch/strcpy-sse2.S "Thomas Schmitt" <scdbackup@gmx.net> - 2015-08-29 10:30 +0200
csiph-web