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

Compiler warning on create_library #532

Closed
KristofferC opened this issue Sep 14, 2021 · 5 comments · Fixed by #535 or #561
Closed

Compiler warning on create_library #532

KristofferC opened this issue Sep 14, 2021 · 5 comments · Fixed by #535 or #561

Comments

@KristofferC
Copy link
Member

In function ‘strncpy’,
    inlined from ‘set_depot_path’ at /home/kc/.julia/packages/PackageCompiler/0A6ug/src/julia_init.c:61:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kc/.julia/packages/PackageCompiler/0A6ug/src/julia_init.c: In function ‘set_depot_path’:
/home/kc/.julia/packages/PackageCompiler/0A6ug/src/julia_init.c:47:24: note: length computed here
   47 |     int root_dir_len = strlen(root_dir);
      |                        ^~~~~~~~~~~~~~~~

cc @kmsquire

@KristofferC
Copy link
Member Author

This still seems to happen. Here is from a recent CI log:

In file included from /usr/include/string.h:495,
                 from /opt/hostedtoolcache/julia/1.6.3/x64/include/julia/dtypes.h:9,
                 from /opt/hostedtoolcache/julia/1.6.3/x64/include/julia/libsupport.h:10,
                 from /opt/hostedtoolcache/julia/1.6.3/x64/include/julia/julia.h:12,
                 from /home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c:13:
In function ‘strncpy’,
    inlined from ‘set_depot_path’ at /home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c:61:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c: In function ‘set_depot_path’:
/home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c:47:24: note: length computed here
   47 |     int root_dir_len = strlen(root_dir);
      |                        ^~~~~~~~~~~~~~~~

https://github.com/JuliaLang/PackageCompiler.jl/runs/3720013049?check_suite_focus=true#step:4:1018

@KristofferC KristofferC reopened this Sep 27, 2021
@KristofferC
Copy link
Member Author

cc @kmsquire

@kmsquire
Copy link
Member

Okay, I should have at least checked that my fix worked. ☹️ Sorry about that...

As far as I can ascertain, this isn't a problem in practice--we're allocating the buffer based on the size, and then using that value in strncpy. I'll try a few things to see if they silence the warning.

  1. using strcpy. Also should be fine because of how we're allocating the buffer, but I'm guessing it'll cause a different compiler warning.
  2. using a large, fixed sized buffer. Seems slightly wasteful, but it would probably silence the compiler warning. Unfortunately, it's hard to determine a good size to set this to, as the actual maximum path length depends on the operating system.

Any other ideas?

@KristofferC
Copy link
Member Author

Seems fine to use strcpy here, or?

@kmsquire
Copy link
Member

Okay, #561 actually fixes this (no warning in the logs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants