-
Notifications
You must be signed in to change notification settings - Fork 159
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
HH\FormatString Typing Errors in sprintf() and invariant() #448
Comments
Which specific parameter is it complaining about? None line up with the column numbers in the error. Anyway, that error is telling you that the parameter must be literal strings, i.e. not a string-typed variable. |
^^^ invalid, not a literal string
^ valid, literal string HH\FormatString is special-cased in the typechecker, using a template interface (PlainSprintf is the relevant one here), so it understands invalid/incorrect format strings + parameters, eg:
|
@fredemmott Thank you for the assistance and response.
From the example error and example code, line 12 is the following line:
Fully understood that the format string passed to In fact, switching the above code to:
Results in the same error:
|
After further testing, it looks like we found the culprit. The original code is passing an
This worked in HHVM 3.14.15 without warning as the We can see the
The second parameter of Changing the above code to the following works and no longer results in any typechecking errors:
@fredemmott Thank you again for your help! |
Closing; for future reference, https://www.facebook.com/groups/hhvm.general/ or #hhvm on Freenode are better places for support. Partially dupe of #209 |
…port (#535) * Separate docker containers per service * Provision Streamlined, Quick Setup Added, and Multiple Containers Support * The project now includes a number of "Quick Setup" options to ease the installation or startup process of the platform. The following Quick Setup modes are available: * Direct Installation - Used when directly installing to the system you are on; this is useful when installing on bare metal, an existing VM, or a cloud-based host. * `source ./extra/lib.sh` * `quick_setup install <dev/prod>` * Multi-Server Direct Installation - Used when directly installing the platform with each service on a separate system; this is useful when installing on bare metal systems, existing VMs, or cloud-based hosts. * Database Server (MySQL) * `source ./extra/lib.sh` * `quick_setup install_multi_mysql <dev/prod>` * Cache Server (Memcached) * `source ./extra/lib.sh` * `quick_setup install_multi_nginx <dev/prod>` * HHVM Server (HHVM) * `source ./extra/lib.sh` * `quick_setup install_multi_hhvm <dev/prod> <IP of MySQL Server> <IP of Memcached Server>` * Web Server (Nginx) * `source ./extra/lib.sh` * `quick_setup install_multi_nginx <dev/prod> <IP of HHVM Server>` * Standard Docker Startup - Used when running FBCTF as a single docker container. * `source ./extra/lib.sh` * `quick_setup start_docker <dev/prod>` * Multi-Container Docker Startup - Used when running FBCTF on docker with each service hosted in a separate docker container. * `source ./extra/lib.sh` * `quick_setup start_docker_multi <dev/prod>` * Standard Vagrant Startup - Used when running FBCTF as a single vagrant container. * `source ./extra/lib.sh` * `quick_setup start_docker <dev/prod>` * Multi-Container Vagrant Startup - Used when running FBCTF on vagrant with each service hosted in a separate vagrant container. * `source ./extra/lib.sh` * `quick_setup start_docker_multi <dev/prod>` * Each installation platform now supports both Production Mode (prod) and Development Mode (dev). * The `provision.sh` script has been streamlined and organized based on the services being installed. The installation process now also includes more logging and error handling. Common and core functionally has been migrated to `lib.sh` where appropriate. Color coding has been added to the various output to make quick visual monitoring of the process easier. * Package installation, specifically the check for existing packages has been updated to fix an issue where packages would sometimes not be installed if a similarly named package was already present on the system. * The `provision.sh` script now supports separate installations for each service using the `--multiple-servers` and `--server-type` options. * HHVM configuration has been updated to run HHVM as a network-service. * Nginx configuration is now included in the platform code base and utilized. * Docker service startup scripts are included for each of the services: * `./extra/mysql/mysql_startup.sh` * `./extra/hhvm/hhvm_startup.sh` * `./extra/nginx/nginx_startup.sh` * This PR fixes the docker installation dependencies issue #534. * This PR includes docker-compose configurations for multi-docker containers, fixing issue #440. * Services on Docker (both single container and multi-container) are now monitored to ensure they do not fail. * This PR updates HHVM to the latest stable version for Ubuntu 14.04, HHVM Version 3.18.1, fixing issue #496. * Attachment/Upload permissions have been corrected across the installation environments. This fixes issues with improper permissions on Docker and Vagrant while still enforcing secure file permissions. This should resolve issues like #280 going forward. * Implemented more strict permissions on he CTF PATH (755 verses 777). * Fixed long-standing, upstream induced, HHVM socket permission issues (like #229), mostly experienced in Docker or after a restart (resulting in a _502 Bad Gateway_): facebook/hhvm#6336. Note that this fix is a temporary workaround until the upstream issue is resolved. * With the introduction of the latest available version of HHVM and the inclusion of multiple-server support, performance increases should be noticeable. This should help alleviate issues like #456. * This PR was derived, in part, from PR #530. * Added Memcached Service Restart to container service script * Added logging of PHP/HHVM version to provision script. * Added logging of PHP Alternatives to provision script. * Composer is now installed with the HHVM binary instead of PHP. * Composer Install is run with the HHVM binary instead of PHP. * The Travis trusty Ubuntu image has been downgraded from `sugilite` to `connie`. * Updated run_tests.sh to have write permissions to settings.ini * Set run_tests.sh to use localhost for DB and MC. * HHVM 3.18+ enforces \HH\FormatString - Invariant calls now are of \HH\FormatString type - All `invariant()` calls that are passing in a variable argument have been updated to use literal strings for the format string. Invariant passes the second (and subsequent) arguments to `sprintf()`. The second parameter of `invariant()` must be a literal string, containing placeholders when needed. More information can be found here: hhvm/user-documentation#448. This change ensures the code is strict compliant in HHVM versions 3.18
Within the Facebook CTF project, we just upgraded from HHVM 3.14.5 to 3.18.1 in our latest PR facebookarchive/fbctf#535.
Now that we are on a newer version of HHVM, we are getting typing errors for a few
sprintf()
andinvariant()
calls. The errors indicate the argument is incompatible withHH\FormatString
.Our understanding is the
HH\FormatString
definition looks like such:We can confirm that the various [relevant] values passed into
sprintf()
andinvariant()
are of typestring
. Even adding instrval()
or additionalis_string()
checks made no difference to the typing errors.Unfortunately, there doesn't seem to be any documentation available on
HH\FormatString
usage or the expectations for it's typing in functions likesprintf()
, as issue #209 is still outstanding. We were hoping someone might have some insight on how to properly useHH\FormatString
or correct this typing error.Here is an example typing error, from
hh_client
:Here is the code-block from the above example error:
The text was updated successfully, but these errors were encountered: