Skip to content

Turn signal handling on in LineEditor - #4

Closed
brandoncorrea wants to merge 1 commit into
jank-lang:jank-snapshot/llvm22from
brandoncorrea:signal-handling
Closed

brandoncorrea wants to merge 1 commit into
jank-lang:jank-snapshot/llvm22from
brandoncorrea:signal-handling

Conversation

@brandoncorrea

Copy link
Copy Markdown

This PR was created to address jank-lang/jank#801 in the Jank project.

Enabling signal handling allows Jank's repl & cpp-repl to leave a clean terminal environment after exit.

@brandoncorrea

Copy link
Copy Markdown
Author

@jeaye pinging you, per jank-lang/jank#801

@jeaye

jeaye commented Jun 5, 2026

Copy link
Copy Markdown
Member

Oh, we need to make a PR to actual LLVM. This is just jank's fork.

@jeaye jeaye closed this Jun 5, 2026
@brandoncorrea

Copy link
Copy Markdown
Author

Aw, bummer ☹️ I'll make a PR to that project at some point then and ping you there (probably not today).

jeaye pushed a commit that referenced this pull request Sep 1, 2026
`target.process.memory-cache-line-size` is an unbounded `UInt64`, so
`settings set` accepts 0, and `MemoryCache` keeps the value in a
`uint32_t`, so it also accepts any multiple of 2^32, which truncates to
0.  Every consumer then takes a remainder by 0.

`Process::ReadCStringFromMemory` divides on the first iteration of its
loop, before it touches inferior memory, so any address reproduces it.
On an x86_64 host that is a `SIGFPE` and lldb dies; on AArch64 `udiv` by
zero yields 0, so `addr % 0` evaluates to `addr` and the subtraction
underflows to a huge chunk size, and the bug hides.

```
$ lldb -b \
    -o 'settings set target.process.memory-cache-line-size 0' \
    -o 'target create --core linux-x86_64.core'
Floating point exception: 8
```

Under UBSan on any host, with
`lldb/test/API/tools/lldb-dap/coreFile/linux-x86_64.core`:

```
lldb/source/Target/Process.cpp:2388:40: runtime error: division by zero
    #0 lldb_private::Process::ReadCStringFromMemory
    #2 ProcessElfCore::GetMainExecutableModuleSpec
    #3 ProcessElfCore::DoLoadCore
    #4 lldb_private::Process::LoadCore
```

The truncating case crashes the same way while `settings show` reports a
value that is not 0, so nothing in the UI hints at the cause:

```
(lldb) settings set target.process.memory-cache-line-size 4294967296
(lldb) settings show target.process.memory-cache-line-size
target.process.memory-cache-line-size (unsigned) = 4294967296
```

The cache uses 0.  4294967297 truncates to 1, so the cache uses a
one-byte line.

Bound the property once instead of at each use, from 1 to `UINT32_MAX`,
the way `Debugger` bounds `term-width` and `term-height`.  Rejecting
beats clamping, because `settings show` reads the stored value back and
would otherwise report a number the cache does not use:

```
(lldb) settings set target.process.memory-cache-line-size 4294967296
error: 4294967296 is out of range, valid values must be between 1 and 4294967295.
```

`OptionValueProperties::CreateLocalCopy` deep-copies the option values,
so the bounds also apply to each process's own collection, not just the
global one.
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 this pull request may close these issues.

2 participants