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

[Q] How to use the linecache #29

Open
Cogitri opened this issue Jun 5, 2019 · 16 comments · Fixed by #30
Open

[Q] How to use the linecache #29

Cogitri opened this issue Jun 5, 2019 · 16 comments · Fixed by #30

Comments

@Cogitri
Copy link
Collaborator

Cogitri commented Jun 5, 2019

Hello,

It appears that I misuse the linecache (or I somehow discovered a weird bug, which may very well be in gxi though?). I'm not 100% certain how to trigger the behaviour I'm going to describe, but it usually happens after working on a document which is rather big for a while. At some point the linecache just bugs out, not giving me the right lines, which manifests s such stuff:

i: 760 line.text: 
i: 761 line.text:                 for x in line_selections {
i: 762 line.text:                 for x in line_selections {
i: 763 line.text:                     if let Some(cur) = begin_selection {
i: 764 line.text:                     if let Some(cur) = begin_selection {
i: 765 line.text:                     if let Some(cur) = begin_selection {
i: 766 line.text:                         // Make sure to use the lowest value of any selection so it's in the view
i: 767 line.text:                     }

The i is the line number (during drawing), the line.text is the text of the line. The duplicates shouldn't be there. Maybe I'm getting the lines during an update of the linecache? My drawing function is a bit primitive and just looks like this:

        for i in first_line..last_line {
            // Keep track of the starting x position
            if let Some(line) = self.line_cache.lines().get(i as usize) {
                 // draw each line with styles
            }
       }

This happens both with gxi using all of xrl and with xrl only using xrl's linecache (Cogitri/Tau@911c4e3 the commit is a bit broken due to rebasing, but after a tiny bit of fixing I could observe the same behaviour).

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 5, 2019

It appears that this only happens with documents which are larger than my view (so need scrolling) - or maybe the load on the linecache just increases at that point?

@little-dude
Copy link
Collaborator

I'm out for today, but do you mind cherry-picking 11b00d0 and sharing the logs? Otherwise I'll give it a try tomorrow.

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 5, 2019

Here's the log: https://gist.github.com/1c117455b09c33e3bd8ded8ce83733b9

Everything starts going wrong at about 38:26/27. I'll look into it tomorrow too, gonna sleep now. Thanks for your help!

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 6, 2019

So, here's a log of just the linecache, which is way easier to read: https://gist.github.com/cdcc742aad2b6d9b6b42fb361b39aea3

What looks really fishy to me:

Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [], line_num: Some(37) }, Line { text: "", cursor: [], styles: [], line_num: Some(38) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "\tDESTDIR=\"$pkgdir\" ninja install", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(68) }, Line { text: "package() {", cursor: [0], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "", cursor: [0], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(64) }, Line { text: "package() {", cursor: [], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "", cursor: [0], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(64) }, Line { text: "package() {", cursor: [], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }

It jumps from line_number 38 to 68, it has line_number 66 twice

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 7, 2019

Maybe this is due to odd timing though? Right now I funnel all XiEvents through a SyncSender to my main thread, which then calls LineCache::update (which is also bad due to that blocking my main thread) - but I'm not exactly sure how to do this in other means.

@little-dude
Copy link
Collaborator

Ok so the last "good" cache is:

[2019-06-06T12:18:25Z TRACE xrl::cache] cache state before: UpdateHelper { old_lines: [Line { text: "# Contributor Travis Tilley <[email protected]>", cursor: [], styles: [], line_num: Some(2) }, Line { text: "# Maintainer: Natanael Copa <[email protected]>", cursor: [], styles: [], line_num: Some(3) }, Line { text: "pkgname=clang", cursor: [], styles: [], line_num: Some(4) }, Line { text: "# Note: Update together with llvm.", cursor: [], styles: [], line_num: Some(5) }, Line { text: "pkgver=8.0.0", cursor: [], styles: [], line_num: Some(6) }, Line { text: "pkgrel=0", cursor: [], styles: [], line_num: Some(7) }, Line { text: "_llvmver=${pkgver%%.*}", cursor: [], styles: [], line_num: Some(8) }, Line { text: "pkgdesc=\"A C language family front-end for LLVM\"", cursor: [], styles: [], line_num: Some(9) }, Line { text: "arch=\"all\"", cursor: [], styles: [], line_num: Some(10) }, Line { text: "url=\"https://llvm.org/\"", cursor: [], styles: [], line_num: Some(11) }, Line { text: "license=\"NCSA\"", cursor: [], styles: [], line_num: Some(12) }, Line { text: "makedepends=\"", cursor: [], styles: [], line_num: Some(13) }, Line { text: "\tcmake", cursor: [], styles: [], line_num: Some(14) }, Line { text: "\tisl-dev", cursor: [], styles: [], line_num: Some(15) }, Line { text: "\tlibedit-dev", cursor: [], styles: [], line_num: Some(16) }, Line { text: "\tlibexecinfo-dev", cursor: [], styles: [], line_num: Some(17) }, Line { text: "\tlibxml2-dev", cursor: [], styles: [], line_num: Some(18) }, Line { text: "\tlibxml2-utils", cursor: [], styles: [], line_num: Some(19) }, Line { text: "\tllvm-dev>=$_llvmver", cursor: [], styles: [], line_num: Some(20) }, Line { text: "\tllvm-static>=$_llvmver", cursor: [], styles: [], line_num: Some(21) }, Line { text: "\tllvm-test-utils>=$_llvmver", cursor: [], styles: [], line_num: Some(22) }, Line { text: "\tninja", cursor: [], styles: [], line_num: Some(23) }, Line { text: "\tpython3", cursor: [], styles: [], line_num: Some(24) }, Line { text: "\t\"", cursor: [], styles: [], line_num: Some(25) }, Line { text: "depends_dev=\"$pkgname=$pkgver-r$pkgrel\"", cursor: [], styles: [], line_num: Some(26) }, Line { text: "subpackages=\"$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs", cursor: [], styles: [], line_num: Some(27) }, Line { text: "\t$pkgname-analyzer::noarch\"", cursor: [], styles: [], line_num: Some(28) }, Line { text: "source=\"https://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz", cursor: [], styles: [], line_num: Some(29) }, Line { text: "\t10-add-musl-triples.patch", cursor: [], styles: [], line_num: Some(30) }, Line { text: "\t20-Enable-stack-protector-by-default-for-Alpine-Linux.patch\"", cursor: [], styles: [], line_num: Some(31) }, Line { text: "", cursor: [], styles: [], line_num: Some(32) }, Line { text: "builddir=\"$srcdir/cfe-$pkgver.src\"", cursor: [], styles: [], line_num: Some(33) }, Line { text: "", cursor: [], styles: [], line_num: Some(34) }, Line { text: "build() {", cursor: [], styles: [StyleDef { offset: 8, length: 2, style_id: 0 }], line_num: Some(35) }, Line { text: "\tmkdir -p \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 28, style_id: 0 }], line_num: Some(36) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(37) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(38) }, Line { text: "\tcmake .. -G Ninja -Wno-dev \\", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(39) }, Line { text: "\t\t-DCMAKE_BUILD_TYPE=MinSizeRel \\", cursor: [], styles: [StyleDef { offset: 0, length: 34, style_id: 0 }], line_num: Some(40) }, Line { text: "\t\t-DCMAKE_C_FLAGS_MINSIZEREL_INIT=\"$CFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 46, style_id: 0 }], line_num: Some(41) }, Line { text: "\t\t-DCMAKE_CXX_FLAGS_MINSIZEREL_INIT=\"$CXXFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(42) }, Line { text: "\t\t-DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT=\"$LDFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 56, style_id: 0 }], line_num: Some(43) }, Line { text: "\t\t-DCMAKE_INSTALL_PREFIX=/usr \\", cursor: [], styles: [StyleDef { offset: 0, length: 32, style_id: 0 }], line_num: Some(44) }, Line { text: "\t\t-DCMAKE_VERBOSE_MAKEFILE=OFF \\", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(45) }, Line { text: "\t\t-DCLANG_VENDOR=Alpine \\", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(46) }, Line { text: "\t\t-DCLANG_BUILD_EXAMPLES=OFF \\", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(47) }, Line { text: "\t\t-DCLANG_INCLUDE_DOCS=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 28, style_id: 0 }], line_num: Some(48) }, Line { text: "\t\t-DCLANG_INCLUDE_TESTS=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(49) }, Line { text: "\t\t-DCLANG_PLUGIN_SUPPORT=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(50) }, Line { text: "\t\t-DLIBCLANG_BUILD_STATIC=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(51) }, Line { text: "\t\t-DLLVM_ENABLE_EH=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(52) }, Line { text: "\t\t-DLLVM_ENABLE_RTTI=ON", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(53) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(54) }, Line { text: "\tninja clang-tblgen", cursor: [], styles: [StyleDef { offset: 0, length: 20, style_id: 0 }], line_num: Some(55) }, Line { text: "\tninja", cursor: [], styles: [StyleDef { offset: 0, length: 7, style_id: 0 }], line_num: Some(56) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(57) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(58) }, Line { text: "check() {", cursor: [], styles: [StyleDef { offset: 0, length: 10, style_id: 0 }], line_num: Some(59) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(60) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(61) }, Line { text: "\tlit -sv --param clang_site_config=$builddir/build/test/lib.site.cfg $builddir/build/test", cursor: [], styles: [StyleDef { offset: 0, length: 90, style_id: 0 }], line_num: Some(62) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(63) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(64) }, Line { text: "package() {", cursor: [], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "\tDESTDIR=\"$pkgdir\" ninja install", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(68) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(69) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(70) }, Line { text: "analyzer() {", cursor: [], styles: [StyleDef { offset: 0, length: 13, style_id: 0 }], line_num: Some(71) }, Line { text: "\tpkgdesc=\"Clang source code analysis framework\"", cursor: [], styles: [StyleDef { offset: 0, length: 48, style_id: 0 }], line_num: Some(72) }, Line { text: "\tdepends=\"$pkgname=$pkgver-r$pkgrel perl python2\"", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(73) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(74) }, Line { text: "\tcd \"$pkgdir\"", cursor: [], styles: [StyleDef { offset: 0, length: 14, style_id: 0 }], line_num: Some(75) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(76) }, Line { text: "\tmkdir -p \"$subpkgdir\"/usr/bin \\", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(77) }, Line { text: "\t\t\"$subpkgdir\"/usr/libexec \\", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(78) }, Line { text: "\t\t\"$subpkgdir\"/usr/share/", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(79) }, Line { text: "\tmv usr/bin/scan-* \"$subpkgdir\"/usr/bin/", cursor: [40], styles: [StyleDef { offset: 0, length: 40, style_id: 0 }], line_num: Some(80) }, Line { text: "\tmv usr/libexec/*-analyzer \"$subpkgdir\"/usr/libexec/", cursor: [], styles: [], line_num: Some(81) }, Line { text: "\tmv usr/share/scan-* \"$subpkgdir\"/usr/share/", cursor: [], styles: [], line_num: Some(82) }, Line { text: "}", cursor: [], styles: [], line_num: Some(83) }, Line { text: "", cursor: [], styles: [], line_num: Some(84) }, Line { text: "sha512sums=\"98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3  cfe-8.0.0.src.tar.xz", cursor: [], styles: [], line_num: Some(85) }, Line { text: "b52cb7d74636d39d12dd6c94a2b2a9c01e4d6a535d151aa8ca49b691eb20e1b4ea08481f1517ef81f4501ebc305a32d7951638cc0385fee134131e827bb0b2f3  10-add-musl-triples.patch", cursor: [], styles: [], line_num: Some(86) }, Line { text: "b98f39354adf7cf09de5bcac498cccb5c5dd4b8ba7ea0e6c18f2f2204650288088a12b7a535451e21a451b890b70430d679a09df7161de03dbf30d6b49ee1ec0  20-Enable-stack-protector-by-default-for-Alpine-Linux.patch\"", cursor: [], styles: [], line_num: Some(87) }, Line { text: "", cursor: [], styles: [], line_num: Some(88) }], old_invalid_before: 1, old_invalid_after: 0, new_lines: [], new_invalid_before: 0, new_invalid_after: 0 }

The operations that messes it up:

[2019-06-06T12:18:25Z TRACE xrl::cache] operations to be applied: [Operation { operation_type: Invalidate, nb_lines: 1, lines: [] }, Operation { operation_type: Skip, nb_lines: 1, lines: [] }, Operation { operation_type: Copy_, nb_lines: 33, lines: [] }, Operation { operation_type: Invalidate, nb_lines: 4, lines: [] }, Operation { operation_type: Insert, nb_lines: 50, lines: [Line { text: "\tcmake .. -G Ninja -Wno-dev \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(39) }, Line { text: "\t\t-DCMAKE_BUILD_TYPE=MinSizeRel \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 34, style_id: 0 }], line_num: Some(40) }, Line { text: "\t\t-DCMAKE_C_FLAGS_MINSIZEREL_INIT=\"$CFLAGS\" \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 46, style_id: 0 }], line_num: Some(41) }, Line { text: "\t\t-DCMAKE_CXX_FLAGS_MINSIZEREL_INIT=\"$CXXFLAGS\" \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(42) }, Line { text: "\t\t-DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT=\"$LDFLAGS\" \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 56, style_id: 0 }], line_num: Some(43) }, Line { text: "\t\t-DCMAKE_INSTALL_PREFIX=/usr \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 32, style_id: 0 }], line_num: Some(44) }, Line { text: "\t\t-DCMAKE_VERBOSE_MAKEFILE=OFF \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(45) }, Line { text: "\t\t-DCLANG_VENDOR=Alpine \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(46) }, Line { text: "\t\t-DCLANG_BUILD_EXAMPLES=OFF \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(47) }, Line { text: "\t\t-DCLANG_INCLUDE_DOCS=ON \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 28, style_id: 0 }], line_num: Some(48) }, Line { text: "\t\t-DCLANG_INCLUDE_TESTS=ON \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(49) }, Line { text: "\t\t-DCLANG_PLUGIN_SUPPORT=ON \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(50) }, Line { text: "\t\t-DLIBCLANG_BUILD_STATIC=ON \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(51) }, Line { text: "\t\t-DLLVM_ENABLE_EH=ON \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(52) }, Line { text: "\t\t-DLLVM_ENABLE_RTTI=ON\n", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(53) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(54) }, Line { text: "\tninja clang-tblgen\n", cursor: [], styles: [StyleDef { offset: 0, length: 20, style_id: 0 }], line_num: Some(55) }, Line { text: "\tninja\n", cursor: [], styles: [StyleDef { offset: 0, length: 7, style_id: 0 }], line_num: Some(56) }, Line { text: "}\n", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(57) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(58) }, Line { text: "check() {\n", cursor: [], styles: [StyleDef { offset: 0, length: 10, style_id: 0 }], line_num: Some(59) }, Line { text: "\tcd \"$builddir\"/build\n", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(60) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(61) }, Line { text: "\tlit -sv --param clang_site_config=$builddir/build/test/lib.site.cfg $builddir/build/test\n", cursor: [], styles: [StyleDef { offset: 0, length: 90, style_id: 0 }], line_num: Some(62) }, Line { text: "}\n", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(63) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(64) }, Line { text: "package() {\n", cursor: [], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build\n", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "\tDESTDIR=\"$pkgdir\" ninja install\n", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(68) }, Line { text: "}\n", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(69) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(70) }, Line { text: "analyzer() {\n", cursor: [], styles: [StyleDef { offset: 0, length: 13, style_id: 0 }], line_num: Some(71) }, Line { text: "\tpkgdesc=\"Clang source code analysis framework\"\n", cursor: [], styles: [StyleDef { offset: 0, length: 48, style_id: 0 }], line_num: Some(72) }, Line { text: "\tdepends=\"$pkgname=$pkgver-r$pkgrel perl python2\"\n", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(73) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(74) }, Line { text: "\tcd \"$pkgdir\"\n", cursor: [], styles: [StyleDef { offset: 0, length: 14, style_id: 0 }], line_num: Some(75) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(76) }, Line { text: "\tmkdir -p \"$subpkgdir\"/usr/bin \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(77) }, Line { text: "\t\t\"$subpkgdir\"/usr/libexec \\\n", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(78) }, Line { text: "\t\t\"$subpkgdir\"/usr/share/\n", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(79) }, Line { text: "\tmv usr/bin/scan-* \"$subpkgdir\"/usr/bin/\n", cursor: [], styles: [StyleDef { offset: 0, length: 41, style_id: 0 }], line_num: Some(80) }, Line { text: "\tmv usr/libexec/*-analyzer \"$subpkgdir\"/usr/libexec/\n", cursor: [], styles: [StyleDef { offset: 0, length: 53, style_id: 0 }], line_num: Some(81) }, Line { text: "\tmv usr/share/scan-* \"$subpkgdir\"/usr/share/\n", cursor: [], styles: [StyleDef { offset: 0, length: 45, style_id: 0 }], line_num: Some(82) }, Line { text: "}\n", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(83) }, Line { text: "\n", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(84) }, Line { text: "sha512sums=\"98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3  cfe-8.0.0.src.tar.xz\n", cursor: [], styles: [StyleDef { offset: 0, length: 163, style_id: 0 }], line_num: Some(85) }, Line { text: "b52cb7d74636d39d12dd6c94a2b2a9c01e4d6a535d151aa8ca49b691eb20e1b4ea08481f1517ef81f4501ebc305a32d7951638cc0385fee134131e827bb0b2f3  10-add-musl-triples.patch\n", cursor: [], styles: [StyleDef { offset: 0, length: 156, style_id: 0 }], line_num: Some(86) }, Line { text: "b98f39354adf7cf09de5bcac498cccb5c5dd4b8ba7ea0e6c18f2f2204650288088a12b7a535451e21a451b890b70430d679a09df7161de03dbf30d6b49ee1ec0  20-Enable-stack-protector-by-default-for-Alpine-Linux.patch\"\n", cursor: [], styles: [StyleDef { offset: 0, length: 191, style_id: 0 }], line_num: Some(87) }, Line { text: "", cursor: [0], styles: [], line_num: Some(88) }] }]

First messed up cache:

[2019-06-06T12:18:26Z TRACE xrl::cache] cache state before: UpdateHelper { old_lines: [Line { text: "# Contributor Travis Tilley <[email protected]>", cursor: [], styles: [], line_num: Some(2) }, Line { text: "# Maintainer: Natanael Copa <[email protected]>", cursor: [], styles: [], line_num: Some(3) }, Line { text: "pkgname=clang", cursor: [], styles: [], line_num: Some(4) }, Line { text: "# Note: Update together with llvm.", cursor: [], styles: [], line_num: Some(5) }, Line { text: "pkgver=8.0.0", cursor: [], styles: [], line_num: Some(6) }, Line { text: "pkgrel=0", cursor: [], styles: [], line_num: Some(7) }, Line { text: "_llvmver=${pkgver%%.*}", cursor: [], styles: [], line_num: Some(8) }, Line { text: "pkgdesc=\"A C language family front-end for LLVM\"", cursor: [], styles: [], line_num: Some(9) }, Line { text: "arch=\"all\"", cursor: [], styles: [], line_num: Some(10) }, Line { text: "url=\"https://llvm.org/\"", cursor: [], styles: [], line_num: Some(11) }, Line { text: "license=\"NCSA\"", cursor: [], styles: [], line_num: Some(12) }, Line { text: "makedepends=\"", cursor: [], styles: [], line_num: Some(13) }, Line { text: "\tcmake", cursor: [], styles: [], line_num: Some(14) }, Line { text: "\tisl-dev", cursor: [], styles: [], line_num: Some(15) }, Line { text: "\tlibedit-dev", cursor: [], styles: [], line_num: Some(16) }, Line { text: "\tlibexecinfo-dev", cursor: [], styles: [], line_num: Some(17) }, Line { text: "\tlibxml2-dev", cursor: [], styles: [], line_num: Some(18) }, Line { text: "\tlibxml2-utils", cursor: [], styles: [], line_num: Some(19) }, Line { text: "\tllvm-dev>=$_llvmver", cursor: [], styles: [], line_num: Some(20) }, Line { text: "\tllvm-static>=$_llvmver", cursor: [], styles: [], line_num: Some(21) }, Line { text: "\tllvm-test-utils>=$_llvmver", cursor: [], styles: [], line_num: Some(22) }, Line { text: "\tninja", cursor: [], styles: [], line_num: Some(23) }, Line { text: "\tpython3", cursor: [], styles: [], line_num: Some(24) }, Line { text: "\t\"", cursor: [], styles: [], line_num: Some(25) }, Line { text: "depends_dev=\"$pkgname=$pkgver-r$pkgrel\"", cursor: [], styles: [], line_num: Some(26) }, Line { text: "subpackages=\"$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs", cursor: [], styles: [], line_num: Some(27) }, Line { text: "\t$pkgname-analyzer::noarch\"", cursor: [], styles: [], line_num: Some(28) }, Line { text: "source=\"https://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz", cursor: [], styles: [], line_num: Some(29) }, Line { text: "\t10-add-musl-triples.patch", cursor: [], styles: [], line_num: Some(30) }, Line { text: "\t20-Enable-stack-protector-by-default-for-Alpine-Linux.patch\"", cursor: [], styles: [], line_num: Some(31) }, Line { text: "", cursor: [], styles: [], line_num: Some(32) }, Line { text: "builddir=\"$srcdir/cfe-$pkgver.src\"", cursor: [], styles: [], line_num: Some(33) }, Line { text: "", cursor: [], styles: [], line_num: Some(34) }, Line { text: "\tcmake .. -G Ninja -Wno-dev \\", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(39) }, Line { text: "\t\t-DCMAKE_BUILD_TYPE=MinSizeRel \\", cursor: [], styles: [StyleDef { offset: 0, length: 34, style_id: 0 }], line_num: Some(40) }, Line { text: "\t\t-DCMAKE_C_FLAGS_MINSIZEREL_INIT=\"$CFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 46, style_id: 0 }], line_num: Some(41) }, Line { text: "\t\t-DCMAKE_CXX_FLAGS_MINSIZEREL_INIT=\"$CXXFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(42) }, Line { text: "\t\t-DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT=\"$LDFLAGS\" \\", cursor: [], styles: [StyleDef { offset: 0, length: 56, style_id: 0 }], line_num: Some(43) }, Line { text: "\t\t-DCMAKE_INSTALL_PREFIX=/usr \\", cursor: [], styles: [StyleDef { offset: 0, length: 32, style_id: 0 }], line_num: Some(44) }, Line { text: "\t\t-DCMAKE_VERBOSE_MAKEFILE=OFF \\", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(45) }, Line { text: "\t\t-DCLANG_VENDOR=Alpine \\", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(46) }, Line { text: "\t\t-DCLANG_BUILD_EXAMPLES=OFF \\", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(47) }, Line { text: "\t\t-DCLANG_INCLUDE_DOCS=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 28, style_id: 0 }], line_num: Some(48) }, Line { text: "\t\t-DCLANG_INCLUDE_TESTS=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(49) }, Line { text: "\t\t-DCLANG_PLUGIN_SUPPORT=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 30, style_id: 0 }], line_num: Some(50) }, Line { text: "\t\t-DLIBCLANG_BUILD_STATIC=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 31, style_id: 0 }], line_num: Some(51) }, Line { text: "\t\t-DLLVM_ENABLE_EH=ON \\", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(52) }, Line { text: "\t\t-DLLVM_ENABLE_RTTI=ON", cursor: [], styles: [StyleDef { offset: 0, length: 24, style_id: 0 }], line_num: Some(53) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(54) }, Line { text: "\tninja clang-tblgen", cursor: [], styles: [StyleDef { offset: 0, length: 20, style_id: 0 }], line_num: Some(55) }, Line { text: "\tninja", cursor: [], styles: [StyleDef { offset: 0, length: 7, style_id: 0 }], line_num: Some(56) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(57) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(58) }, Line { text: "check() {", cursor: [], styles: [StyleDef { offset: 0, length: 10, style_id: 0 }], line_num: Some(59) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(60) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(61) }, Line { text: "\tlit -sv --param clang_site_config=$builddir/build/test/lib.site.cfg $builddir/build/test", cursor: [], styles: [StyleDef { offset: 0, length: 90, style_id: 0 }], line_num: Some(62) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(63) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(64) }, Line { text: "package() {", cursor: [], styles: [StyleDef { offset: 0, length: 12, style_id: 0 }], line_num: Some(65) }, Line { text: "\tcd \"$builddir\"/build", cursor: [], styles: [StyleDef { offset: 0, length: 22, style_id: 0 }], line_num: Some(66) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(67) }, Line { text: "\tDESTDIR=\"$pkgdir\" ninja install", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(68) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(69) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(70) }, Line { text: "analyzer() {", cursor: [], styles: [StyleDef { offset: 0, length: 13, style_id: 0 }], line_num: Some(71) }, Line { text: "\tpkgdesc=\"Clang source code analysis framework\"", cursor: [], styles: [StyleDef { offset: 0, length: 48, style_id: 0 }], line_num: Some(72) }, Line { text: "\tdepends=\"$pkgname=$pkgver-r$pkgrel perl python2\"", cursor: [], styles: [StyleDef { offset: 0, length: 50, style_id: 0 }], line_num: Some(73) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(74) }, Line { text: "\tcd \"$pkgdir\"", cursor: [], styles: [StyleDef { offset: 0, length: 14, style_id: 0 }], line_num: Some(75) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(76) }, Line { text: "\tmkdir -p \"$subpkgdir\"/usr/bin \\", cursor: [], styles: [StyleDef { offset: 0, length: 33, style_id: 0 }], line_num: Some(77) }, Line { text: "\t\t\"$subpkgdir\"/usr/libexec \\", cursor: [], styles: [StyleDef { offset: 0, length: 29, style_id: 0 }], line_num: Some(78) }, Line { text: "\t\t\"$subpkgdir\"/usr/share/", cursor: [], styles: [StyleDef { offset: 0, length: 26, style_id: 0 }], line_num: Some(79) }, Line { text: "\tmv usr/bin/scan-* \"$subpkgdir\"/usr/bin/", cursor: [], styles: [StyleDef { offset: 0, length: 41, style_id: 0 }], line_num: Some(80) }, Line { text: "\tmv usr/libexec/*-analyzer \"$subpkgdir\"/usr/libexec/", cursor: [], styles: [StyleDef { offset: 0, length: 53, style_id: 0 }], line_num: Some(81) }, Line { text: "\tmv usr/share/scan-* \"$subpkgdir\"/usr/share/", cursor: [], styles: [StyleDef { offset: 0, length: 45, style_id: 0 }], line_num: Some(82) }, Line { text: "}", cursor: [], styles: [StyleDef { offset: 0, length: 2, style_id: 0 }], line_num: Some(83) }, Line { text: "", cursor: [], styles: [StyleDef { offset: 0, length: 1, style_id: 0 }], line_num: Some(84) }, Line { text: "sha512sums=\"98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3  cfe-8.0.0.src.tar.xz", cursor: [], styles: [StyleDef { offset: 0, length: 163, style_id: 0 }], line_num: Some(85) }, Line { text: "b52cb7d74636d39d12dd6c94a2b2a9c01e4d6a535d151aa8ca49b691eb20e1b4ea08481f1517ef81f4501ebc305a32d7951638cc0385fee134131e827bb0b2f3  10-add-musl-triples.patch", cursor: [], styles: [StyleDef { offset: 0, length: 156, style_id: 0 }], line_num: Some(86) }, Line { text: "b98f39354adf7cf09de5bcac498cccb5c5dd4b8ba7ea0e6c18f2f2204650288088a12b7a535451e21a451b890b70430d679a09df7161de03dbf30d6b49ee1ec0  20-Enable-stack-protector-by-default-for-Alpine-Linux.patch\"", cursor: [], styles: [StyleDef { offset: 0, length: 191, style_id: 0 }], line_num: Some(87) }, Line { text: "", cursor: [0], styles: [], line_num: Some(88) }], old_invalid_before: 1, old_invalid_after: 4, new_lines: [], new_invalid_before: 0, new_invalid_after: 0 }

@little-dude
Copy link
Collaborator

@Cogitri do you have the full logs corresponding the the "cleaned up" logs you shared? It seems that the first gist is from a different dump.

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 7, 2019

Ah, I can make full logs in a bit, those are from different runs indeed.

@little-dude
Copy link
Collaborator

That's fine, don't worry. The first dump will be enough in case I need to try to debug timing issues.

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 7, 2019

Alright, thank you very much for looking into this!

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 8, 2019

Heh, seems like GitHub tried to be too smart on this one?

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 11, 2019

Huh, I just tested this again with gxi-linecache changed a bit to work with xrl's Updates and now I have the same bug. I suppose this is something in gxi then, I'll report back once I find more.

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 11, 2019

Alright, I think I've figured it out.

I did a bit of debugging with gxi v0.8.1, the last release before I've switched to xrl.

First I serialized a Value to an Update and then back to a Value to make sure serialization worked correctly ( see Cogitri/Tau@7b208a2), which it did, everything seemed normal.

Then I switched it over to just use Update, this broke things: Cogitri/Tau@b931d45

Using a Vec<Option<Line>> for Linecache.lines seems like the way to go, Cogitri/Tau@f807477 fixed it and now everything appears to work correctly.

Sorry that the commits aren't super tidy, I guess I should sleep now :)

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 12, 2019

See https://github.com/Cogitri/gxi/tree/gxi-linecache for a version of gxi that uses xrl for everything but the cache for debugging purposes :)

@little-dude
Copy link
Collaborator

I'm a little confused: do you think your fix to gxi's line cache should be transposed to xrl's ?

@Cogitri
Copy link
Collaborator Author

Cogitri commented Jun 13, 2019

Ah, no, I still think we should go with xrl's LineCache due to xrl's version being faster, but while looking for what caused this I thought it'd be easiest to just try and replicate this issue on something known good in this regard, maybe my write-up about it helps :)

Sorry that I wasn't clear on this :)

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

Successfully merging a pull request may close this issue.

2 participants