Skip to content

Commit

Permalink
chore(lua): turn off all optimizations in debug mode
Browse files Browse the repository at this point in the history
I'm on macOS right now, so not sure how this will look in GCC, but at
least with clang/lldb we find the smoking gun pretty directly here.

First, without `-O0`

    lldb --file nvim
    (lldb) r
    Process 33400 stopped
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x7669746967750013)
        frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match + 52
    commandt.so`commandt_calculate_match:
    ->  0x103411c08 <+52>: ldr    x8, [x8, #0x8]
        0x103411c0c <+56>: adds   x8, x8, #0x1
        0x103411c10 <+60>: cset   w8, eq
        0x103411c14 <+64>: mov    w9, #0x1
    Target 0: (nvim) stopped.
    (lldb) bt
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x29)
      * frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match + 52
        frame #1: 0x0000000103413174 commandt.so`match_thread + 252
        frame #2: 0x00000001be24826c libsystem_pthread.dylib`_pthread_start + 148

Same with `-O0`:

    Process 33773 stopped
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x7669746967750093)
        frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match(haystack=0x766974696775008b, matcher=0x0000600002166800) at match.c:132:38
       129       matchinfo_t m;
       130       /* long i; */
       131       float score = 1.0;
    -> 132       int compute_bitmasks = haystack->bitmask == UNSET_BITMASK;
       133       m.haystack = haystack;
       134       m.needle_p = matcher->needle;
       135       m.needle_length = matcher->needle_length;
    Target 0: (nvim) stopped.
  • Loading branch information
wincent committed Jul 7, 2022
1 parent 5ef5ec2 commit 53671de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/wincent/commandt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CC = gcc
CCFLAGS += -Wall -Wextra -Wno-unused-parameter

ifdef DEBUG
CCFLAGS += -DDEBUG -g
CCFLAGS += -DDEBUG -g -O0
endif

DLLEXT := so
Expand Down

0 comments on commit 53671de

Please sign in to comment.