Skip to content

OpenBSD support#2912

Open
mischief wants to merge 2 commits intodankamongmen:masterfrom
mischief:master
Open

OpenBSD support#2912
mischief wants to merge 2 commits intodankamongmen:masterfrom
mischief:master

Conversation

@mischief
Copy link
Copy Markdown

partially fixes #2088 by adding OpenBSD support in the notcurses tree.

while some of the demo programs work, notcurses-demo does not and exits immediately:

fugu$ ./notcurses-demo
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
RGB emits:elides: def 0:0 fg 0:0 bg 0:0
Cell emits:elides: 0:0 (0.00%) 0.00% 0.00% 0.00%
Bmap emits:elides: 0:0 (0.00%) 0B (0.00%) SuM: 0 (0.00%)

i'm not sure how to identify what is wrong with it.

@dankamongmen
Copy link
Copy Markdown
Owner

exciting! let me take a look. i'll also install an openbsd vm so i can test and assist with debugging. thanks for this work!

@dankamongmen
Copy link
Copy Markdown
Owner

i think (and i hope you'll agree) that notcurses-demo is a necessary litmus for considering this a successful extension to openbsd?

the first thing you might want to do is run notcurses-demo -l8 to turn up the logging.

@mischief
Copy link
Copy Markdown
Author

i think (and i hope you'll agree) that notcurses-demo is a necessary litmus for considering this a successful extension to openbsd?

the first thing you might want to do is run notcurses-demo -l8 to turn up the logging.

here's with logging. it does not reveal much more. (level 8 was not valid)

fugu$ ./notcurses-demo -l7
get_tty_fd:482:returning TTY fd 3
notcurses_stop_minimal:176:restored terminal, returning 0
notcurses_drop_planes:1438:we have some planes
ncpile_drop:1419:killing plane 0x9df725b1ee0, next is 0x0
notcurses_drop_planes:1446:all planes dropped
stop_inputlayer:2661:tearing down input thread
free_terminfo_cache:199:brought down input layer
free_terminfo_cache:215:destroyed terminfo cache
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
RGB emits:elides: def 0:0 fg 0:0 bg 0:0
Cell emits:elides: 0:0 (0.00%) 0.00% 0.00% 0.00%
Bmap emits:elides: 0:0 (0.00%) 0B (0.00%) SuM: 0 (0.00%)

@dankamongmen
Copy link
Copy Markdown
Owner

i think the error output is possibly being hidden. can you try the following two things:

  1. run with -k to disable the alternate screen
  2. ensure you're supplying a valid data directory with -p (from a build directory without having installed, try ./notcurses-demo -p ../data

and see if anything interesting happens? i do not see myself getting an openbsd vm installed today.

@mischief
Copy link
Copy Markdown
Author

i think the error output is possibly being hidden. can you try the following two things:

1. run with `-k` to disable the alternate screen

2. ensure you're supplying a valid data directory with `-p` (from a build directory without having installed, try `./notcurses-demo -p ../data`

and see if anything interesting happens? i do not see myself getting an openbsd vm installed today.

using ./notcurses-demo -p ../data -k -l7 2> notcurses-log.txt, here is the log:
notcurses-log.txt

near the end is

handoff_initial_responses_late:1209:handing off initial responses
block_on_input:2490:blocking on input availability
block_on_input:2545:waiting on 1 fds (ibuf: 0/1024)
apply_term_heuristics:986:tname is screen (qterm 8)
ncplane_new_internal:682:created new 61x213 plane "std" @ 0x0
notcurses_drop_planes:1438:we have some planes
ncpile_drop:1419:killing plane 0xcc74e142e00, next is 0x0
notcurses_drop_planes:1446:all planes dropped
utf8_egc_len:139:prohibited or invalid unicode: 0x00000000
notcurses_stop:1450:stopping notcurses
notcurses_stop_minimal:176:restored terminal, returning 0
notcurses_drop_planes:1438:we have some planes
ncpile_drop:1419:killing plane 0xcc74e142e00, next is 0x0
notcurses_drop_planes:1446:all planes dropped
stop_inputlayer:2661:tearing down input thread
free_terminfo_cache:199:brought down input layer
free_terminfo_cache:215:destroyed terminfo cache
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
RGB emits:elides: def 0:0 fg 0:0 bg 0:0
Cell emits:elides: 0:0 (0.00%) 0.00% 0.00% 0.00%
Bmap emits:elides: 0:0 (0.00%) 0B (0.00%) SuM: 0 (0.00%)

is utf8_egc_len:139:prohibited or invalid unicode: 0x00000000 making the demo terminate?

@dankamongmen
Copy link
Copy Markdown
Owner

is utf8_egc_len:139:prohibited or invalid unicode: 0x00000000 making the demo terminate?

nope (it's coming after notcurses_drop_planes(), which is in the shutdown sequence. it's unexpected, though. perhaps that's coming from the input thread?

i see you're running in screen. does this happen outside of screen?

@mischief
Copy link
Copy Markdown
Author

is utf8_egc_len:139:prohibited or invalid unicode: 0x00000000 making the demo terminate?

nope (it's coming after notcurses_drop_planes(), which is in the shutdown sequence. it's unexpected, though. perhaps that's coming from the input thread?

i see you're running in screen. does this happen outside of screen?

it's OpenBSD tmux (sets TERM=screen, same behavior with screen-256color). outside of tmux the behavior is identical - linux TERM=st-256color -> ssh to OpenBSD 7.8: it starts and then exits without drawing.

@mischief
Copy link
Copy Markdown
Author

checked xterm (TERM=xterm-256color), same behavior.

@dankamongmen
Copy link
Copy Markdown
Owner

thanks. i'll need to set up an openbsd vm to debug this. i appreciate you running those tests and starting this work!

@mischief
Copy link
Copy Markdown
Author

is utf8_egc_len:139:prohibited or invalid unicode: 0x00000000 making the demo terminate?

so the bug is here.

gdb$ bt
#0  _libc_mbrtowc (pwc=0x71b5e92a36ec L"__\xaedc427_\xaedebf8_\x3075810_\x3075179_\xaedebee_\x7cea4d84\x57af24aa\xe92a3750__\xf0cb31b_\xaedebee0", s=0xe343075179b "", n=0x4, ps=<optimized out>) at /usr/src/lib/libc/locale/multibyte_citrus.c:53
#1  0x00000e36f0cb4054 in utf8_egc_len (gcluster=0xe343075179b "", colcount=0x71b5e92a3734) at /home/mischief/src/notcurses/src/lib/egcpool.h:113
#2  0x00000e36f0cb31b6 in nccell_load (n=0xe36aedebee0, c=0xe36aedebf80, gcluster=0xe343075179b "") at /home/mischief/src/notcurses/src/lib/notcurses.c:1838
#3  nccell_prime (n=0xe36aedebee0, c=0xe36aedebf80, gcluster=0xe343075179b "", stylemask=0x4, channels=0x71b5e92a3650) at /home/mischief/src/notcurses/include/notcurses/notcurses.h:756
#4  ncplane_set_base (ncp=0xe36aedebee0, egc=0xe343075179b "", stylemask=0x4, channels=0x71b5e92a3650) at /home/mischief/src/notcurses/src/lib/notcurses.c:1569
#5  0x00000e34307a4424 in scrub_stdplane (nc=0xe36aedc4270) at /home/mischief/src/notcurses/src/demo/demo.c:507
#6  main (argc=<optimized out>, argv=<optimized out>) at /home/mischief/src/notcurses/src/demo/demo.c:568

quoth the manual

RETURN VALUES
     0             The bytes pointed to by s form a terminating NUL character.
                   If wc is not NULL, a NUL wide character has been stored in
                   the wchar_t object pointed to by wc.

we pass an empty string so, in utf8_egc_len mbrtowc returns 0, which is not handled. then we fall through to

        if(iswcntrl(wc)){                                                                                                                                     
          logerror("prohibited or invalid unicode: 0x%08x", (unsigned)wc);                                                                                    
          return -1;                                                                                                                                          
        }                                                                                                                                                     

where iswcntrl returns true for the null byte.

i admit i am wholly unfamiliar with wide/multibyte character programming. should utf8_egc_len break the loop when mbrtowc returns 0?

partially fixes dankamongmen#2088 by adding OpenBSD support in the notcurses tree.
@mischief
Copy link
Copy Markdown
Author

mischief commented Feb 9, 2026

i added my change to handle NUL bytes from mbrtowc, and dropped the change to CMakeLists.txt since commit openbsd/src@80c5435 upstream added ncursesw pkg-config files.

@dankamongmen can you take another look?

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.

get building on OpenBSD and submit a port

2 participants