Bug in ODBC Driver (SEGFAULT) - including full reproduction

rickboyd
New Contributor

This gist explains in detail, including root cause and reproduction: https://gist.github.com/rick-boyd-hightouch/35ff96d96edd2d15c39205c4b56527e4

Basically the start/end parsing added for SQL scripting counts any `--` in the SQL text as a comment initiation, and can cause stack overflows on long lines due to recursive regex parsing per-character. There are no workarounds discovered so far, and the earlier versions of the driver (<= 2.9.2) are not available in ARM, so we are stuck...

iyashk-DB
Databricks Employee
Databricks Employee

The std::regex recursive executor in libstdc++ has been a known footgun for patterns like '[^\r\n]*' or '[\s\S]*?' over user-controlled input; every character consumed by the repetition adds a stack frame, so this was always going to blow up on long inputs.

For the immediate workaround: if your SQL is machine-generated and you have any control over the generator, inserting a newline periodically (or specifically after any -- sequence) is probably the most reliable short-term fix. It breaks the condition the regex needs to blow the stack. It's fragile for arbitrary input but works well for templated or DSL-generated queries.

On ARM you're stuck since 2.9.2 never shipped for that arch, so the line-break injection is the only viable path until a fix lands.