0

I'm trying to compile my homework and I needed to recreate strlwr() (only available on Windows), and I'm getting this error:

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65      ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.

I'm using this strlwr().

I found the code for strlen-avx2.S, but I can't find it in my system.

If I use this one, there's no mention of strlen-avx2.S, but still getting segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
0x000055555555532d in strlwr (str=0x0) at parser.c:36
36              while (*p) {
  • 2
    `str=0x0`: You have called your `strlwr` function with a null pointer instead of a valid string. It's not written to handle that. Either don't do that, or else add the appropriate check. – Nate Eldredge Apr 05 '19 at 05:21
  • That's not a good implementation of `strlwr()` — it scans the string twice when once is sufficient. Consider: `char *strlwr(char *str) { for (char *p = str; *p != '\0'; p++) *p = tolower((unsigned char)*p); return str; }` — the cast is a good (necessary) feature of the code (in the original that I'm deconstructing and reconstructing). – Jonathan Leffler Apr 05 '19 at 05:56

0 Answers0