-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Environment
OS: Ubuntu 20.04 (running in a VirtualBox VM)
CodeQL Version: CodeQL command-line toolchain release 2.23.2
Shell: /bin/bash
Problem Description
The codeql query run command consistently fails with a shell syntax error. This happens even on the simplest "Hello World" C file and with a minimal query.
The root cause appears to be a bug in the CodeQL CLI itself, which generates a malformed temporary shell script in the /tmp directory. This script contains a stray continue statement at the very end, which is not inside a loop and causes the script execution to fail.
Steps to Reproduce
Create a simple C file named hello.c
#include <stdio.h>
int main() {
printf("hello, world\n");
return 0;
}
Create a CodeQL database from this file
codeql database create db-hello --language=cpp --command="gcc -c hello.c"
Create a minimal query file named FindMain.ql
import cpp
from Function f
where f.hasGlobalName("main")
select f, "This is the main function."
Attempt to run the query
codeql query run FindMain.ql --database=db-hello
Expected Behavior
The query should run successfully and print the results for the main function.
Actual Behavior
The command fails with the following shell error:
/tmp/codeql.XXXX: continue: XX: not in while, until, select, or repeat loop
Diagnostic Information
The temporary script generated by the CodeQL CLI is malformed. The content of the script (/tmp/codeql.LlkfAXjE) is as follows, with the invalid continue command on the final line:
jvmArgs=' -Xmx1800M'
export CODEQL_ARGV3='--off-heap-ram=1053'
export CODEQL_ARGV4='--verbosity=progress'
export CODEQL_ARGV5='--logdir=/home/vboxuser/Documents/SCOPE-QL/scope/log'
export CODEQL_ARGV6='--evaluator-log-level=5'
export CODEQL_ARGV7='--warnings=show'
export CODEQL_ARGV8='--qlconfig-file=/home/vboxuser/Documents/SCOPE-QL/qlconfig.yml'
export CODEQL_ARGV9='--dynamic-join-order-mode=none'
export CODEQL_ARGV10='--output=/home/vboxuser/Documents/SCOPE-QL/structure.bqrs'
export CODEQL_ARGV13='path:/home/vboxuser/Documents/SCOPE-QL/FunctionStructure.ql'
cleanupAfterJvmTermination='unset CODEQL_ARGV3 CODEQL_ARGV4 CODEQL_ARGV5 CODEQL_ARGV6 CODEQL_ARGV7 CODEQL_ARGV8 CODEQL_ARGV9 CODEQL_ARGV10 CODEQL_ARGV13'
set -- \
'env_argv' \
'execute' \
'queries' \
'-J-Xmx1800M' \
'_' \
'_' \
'_' \
'_' \
'_' \
'_' \
'_' \
'_' \
'--' \
'/home/vboxuser/Documents/SCOPE-QL/scope/db-cpp' \
'_'
continue