Skip to content

Draft: Debug relative breakpoint URL path crash

Igor Kushnir requested to merge work/debug-relative-bp-url-path-crash into master

OUTPUT:

setData QUrl("file:noprefix") true "noprefix" false false "noprefix"
setLocation QUrl("file:noprefix") 0
open document: QUrl("file:noprefix") true "noprefix" false false "noprefix" false
createViewWidget QUrl("file:noprefix") true true "noprefix" false false "noprefix" "file"
empty normalized
"" QUrl("")
toUrl() QUrl("http://noprefix") "noprefix"
toUrl() QUrl("http://noprefix") "noprefix"
toUrl() QUrl("http://noprefix") "noprefix"
toUrl() QUrl("http://noprefix") "noprefix"
setData QUrl("file:./dotslash") true "./dotslash" false false "./dotslash"
setLocation QUrl("file:./dotslash") 0
open document: QUrl("file:dotslash") true "dotslash" false false "dotslash" false
createViewWidget QUrl("file:dotslash") true true "dotslash" false false "dotslash" "file"
empty normalized
"" QUrl("")
toUrl() QUrl("http://dotslash") "dotslash"
toUrl() QUrl("http://dotslash") "dotslash"
toUrl() QUrl("http://dotslash") "dotslash"
toUrl() QUrl("http://dotslash") "dotslash"
setData QUrl("file:../dotdotslash") true "../dotdotslash" false false "../dotdotslash"
setLocation QUrl("file:../dotdotslash") 0
open document: QUrl("file:../dotdotslash") true "../dotdotslash" false false "../dotdotslash" false
createViewWidget QUrl("file:../dotdotslash") true true "../dotdotslash" false false "../dotdotslash" "file"
empty normalized
"" QUrl("")
toUrl() QUrl("") "../dotdotslash"
ASSERT: "!ret.isRelative()" in file /path/to/kdevelop/kdevplatform/serialization/indexedstring.cpp, line 330
*** Program received signal SIGABRT (Aborted) ***

ANALYSIS:

  1. See https://doc.qt.io/qt-5/qurl.html#relative-urls-vs-relative-paths
  2. An IndexedString assertion fails given a relative ../ URL path.
  3. IndexedString produces a wrong URL scheme (http) given a relative ./ URL path.

PROPOSED FIX:

Sanitize breakpoint URLs constructed from user input and read from config:

  1. Add && QFileInfo(url.path()).isAbsolute() into isSupportedBreakpointUrl().
  2. If an URL read from config is unsupported (a relative URL path or a user edited the config file ~/.local/share/kdevelop/sessions/{session-UUID}/sessionrc and produced a relative URL or an URL with an empty filename), set it to an empty URL.
  3. Is there any other way to assign an unsupported URL to a breakpoint that needs to be prevented?

Merge request reports