Bug 267606 - x11-drivers/xf86-video-nv: Segmentation Fault post update from 1.20.14,1 to 21.1.4
Summary: x11-drivers/xf86-video-nv: Segmentation Fault post update from 1.20.14,1 to 2...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL:
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2022-11-06 18:43 UTC by Huskers
Modified: 2024-04-06 20:55 UTC (History)
6 users (show)

See Also:
koobs: maintainer-feedback? (x11)


Attachments
Xorg Log (35.23 KB, text/plain)
2022-11-06 18:43 UTC, Huskers
no flags Details
pkg version list txt file (93.77 KB, text/plain)
2022-11-08 02:55 UTC, Huskers
no flags Details
Tosha_db_Xorg.log (52.06 KB, text/plain)
2023-01-17 23:12 UTC, Sergiy
no flags Details
Patch that would pressumably let the strcmp() pass, edited as previous patch was not correct. (1.02 KB, patch)
2024-01-24 01:30 UTC, Yusuf Khan
no flags Details | Diff
Xorg.0.log OpenBSD xorg-server 1.21.1.8 + NV module version 2.1.22 (37.26 KB, text/plain)
2024-01-29 20:56 UTC, Sergiy
no flags Details
gdb result (driver xf86-video-nv-2.1.22 unchanged, default). (13.74 KB, text/plain)
2024-01-29 21:01 UTC, Sergiy
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Huskers 2022-11-06 18:43:12 UTC
Created attachment 237908 [details]
Xorg Log

OS Details :- 
FreeBSD 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC amd64

I have an old NVIDIA card and use NV driver post 1.20 as nvidia-304 driver does not work.

Here is an interesting issue with my setup:- 

Post update from 1.20.14,1 to any latest versions post May causes segmentation fault on my 32" monitor

Had to revert back to 1.20.14.1 along with xf86-video-nv (xf86-video-nv-2.1.21_4) and driver after this version causes the old Xorg driver to fail.

Attached log file
Comment 1 Huskers 2022-11-06 18:46:01 UTC
The latest versions of work with the same driver on my older monitor of 17" but does not my LG 32"
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2022-11-06 22:06:43 UTC
@Reporter Could you please include `pkg version -v output` (as an attachment), and if you are able to...

Obtain a backtrace of the faulting process using gdb or similar debugger, either by identifying a *.core file associated with the crash, or running the xorg process under gdb
Comment 3 Huskers 2022-11-08 02:55:10 UTC
Created attachment 237932 [details]
pkg version list txt file

Attaching pkg version list as requested
Comment 4 Huskers 2022-11-08 02:56:10 UTC
(In reply to Kubilay Kocak from comment #2)
I never debugged so I will read through documentation and try to get it for you. If you have any suggestions in the meanwhile let me know.
Comment 5 Sergiy 2022-11-22 10:22:01 UTC
I have a similar problem after updating:

xorg-server: 1.20.14,1 -> 21.1.4_1,1
...
xf86-video-nv: 2.1.21_4 -> 2.1.21_5

[   185.079] (EE) Segmentation fault at address 0x0
[   185.079] (EE) 
Fatal server error:
[   185.079] (EE) Caught signal 11 (Segmentation fault). Server aborting
[   185.079] (EE) 
[   185.079] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[   185.079] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[   185.079] (EE) 
[   185.089] (EE) Server terminated with error (1). Closing log file.

My setup:
portable computer Toshiba Satellite A200-1GS with an graphics card nVidia GeForce Go 7300.

GPU: G72M [Quadro NVS 110M/GeForce Go 7300]

I tried:
# pkg update -f 
# pkg upgrade -f

and reinstall xorg-server and xf86-video-nv
It didn't help.

Since then, I have been using xorg-server-21.1.4_1,1 and xf86-video-vesa 2.5.0_1.
Sorry, I thought it was just my local problem.
Sorry for my English.
Comment 6 Huskers 2022-12-05 23:09:02 UTC
(In reply to Sergiy from comment #5)
I had the same issue and now I have locked my xorg to 1.20.14,1 

If backtrace is needed, can anyone guide me on how to do a backtrace?
Comment 7 Sergiy 2022-12-09 14:02:48 UTC
(In reply to Huskers from comment #6)
I tried but I have a problem. It’s my problem.
When installing FreeBSD on my Toshiba, I didn't select the necessary debugging components, e.g
kernel-dbg - Kernel and modules with debug symbols activated...
As a result, to debugging (even with the system hardening turned off) the dump of the Xorg.core file formed after the xorg-server crash, in my opinion, does not provide the necessary information.
In my case, as an option, you can try to install the necessary components in the kernel (bsdinstall), but the problem is that some changes have already taken place in the system - patches that came out p1, p2, p3, p4, p5. I feel insecure...

What I did from what I understood.
By default, the system has the lldb debugger installed.
$ man lldb

I tried the following:
# lldb -c /path_to_file/Xorg.core
in my case:
# lldb -c /home/Black_N/Xorg.core
if the launch of X took place under root, it is possible:
# lldb -c /Xorg.core

then you need to run a command for backtrace — bt
An example of what I got:

root@T0SHA:/home/Black_N # lldb -c Xorg.core
(lldb) target create --core "Xorg.core"
Core file '/home/Black_N/Xorg.core' (x86_64) was loaded.
(lldb) bt
* thread #1, name = 'Xorg', stop reason = signal SIGABRT
  * frame #0: 0x00000008293d633a
    frame #1: 0x000000082934ec74
(lldb) quit

command (quit or exit) - to exit the debugger

To use the gdb debugger, it must first be installed:
# pkg install gdb
After installing gdb, a more complete man page for it will be available
$ man gdb

In my case, the launch is from the user's directory, so I executed/got:

# gdb -c Xorg.core
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
[New LWP 100146]
[New LWP 100147]
Core was generated by `/usr/local/libexec/Xorg :0 -auth /root/.serverauth.1055'.
Program terminated with signal SIGABRT, Aborted.
Sent by thr_kill() from pid 1069 and user 0.
#0  0x00000008293d633a in ?? ()
[Current thread is 1 (LWP 100146)]
(gdb) bt
#0  0x00000008293d633a in ?? ()
#1  0x000000082934ec74 in ?? ()
#2  0x0000000000018732 in ?? ()
#3  0xe0e2e1da422b1897 in ?? ()
#4  0x0000000820e57fa4 in ?? ()
#5  0x0000000820e588c0 in ?? ()
#6  0x0000000820e57fc0 in ?? ()
#7  0x0000000829400109 in ?? ()
#8  0xe0e2e1da422b1897 in ?? ()
#9  0x0000000000000000 in ?? ()
(gdb) exit

But the data is not informative, since the kernel lacks the necessary components...
I did this for the first time, sorry, maybe I'm wrong.

Related to the topic, there is a newer version of the nv driver on the X.org website, maybe when it is ported, it will also solve our problem

www.x.org/releases/individual/driver/

xf86-video-nv-2.1.22    	2022-07-27

Sorry for my English.
Comment 8 Gary Jennejohn 2022-12-09 16:11:03 UTC
(In reply to Sergiy from comment #7)
Your English is very good, so no need for apologies.

Xorg is not compiled with a debug flag (-g) and it is stripped upon installation
so that debug symbols not would be present in any case.

So, this is not due to an error on your part.  kernel debug has nothing to do with userland debug and even if you had enabled that there still would not be any debug symbols in Xorg.
Comment 9 Sergiy 2022-12-22 14:53:03 UTC
(In reply to Gary Jennejohn from comment #8)

Thank You!

I also tried another way that I found on the FreeBSD forum. This is a small chance:

# lldb /usr/local/libexec/Xorg
r
[wait for segfault]
bt

But after entering the command:
r
everything freezes, the screen shows a white cursor, and a white mouse arrow in the center of the screen, the keyboard and mouse do not respond…
I had to turn off the computer with the power button.

The pre-run ʼscriptʼ saved the following information:

Script started on Thu Dec 22 12:47:23 2022
root@T0SHA:/home/Black_N # lldb /usr/local/libexec/Xorg
(lldb) target create "/usr/local/libexec/Xorg"
Current executable set to '/usr/local/libexec/Xorg' (x86_64).
(lldb) r
Process 1026 launched: '/usr/local/libexec/Xorg' (x86_64)

X.Org X Server 1.21.1.4
X Protocol Version 11, Revision 0
Current Operating System: FreeBSD T0SHA.local.info 13.1-RELEASE-p3 FreeBSD 13.1-RELEASE-p3 GENERIC amd64
 
Current version of pixman: 0.42.2
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Thu Dec 22 12:48:06 2022
(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
Process 1026 stopped
* thread #1, name = 'Xorg', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x00000008007c1dec libc.so.7`strcmp + 60
libc.so.7`strcmp:
->  0x8007c1dec <+60>: movq   0x8(%rdi), %rax
    0x8007c1df0 <+64>: addq   $0x8, %rdi
    0x8007c1df4 <+68>: movq   0x8(%rsi), %rdx
    0x8007c1df8 <+72>: addq   $0x8, %rsi
(lldb) $ 

That's all I got...

Yes, gdb at such a start reports:
(No debugging symbols found in /usr/local/libexec/Xorg)

And:
Script started on Thu Dec 22 15:15:59 2022
root@T0SHA:/home/Black_N # gdb /usr/local/libexec/Xorg
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/libexec/Xorg...
(No debugging symbols found in /usr/local/libexec/Xorg)
(gdb) cont
The program is not being run.
(gdb) run
Starting program: /usr/local/libexec/Xorg 
warning: Could not load shared library symbols for [vdso].
Do you need "set solib-search-path" or "set sysroot"?
[New LWP 100146 of process 1048]

X.Org X Server 1.21.1.4
X Protocol Version 11, Revision 0
Current Operating System: FreeBSD T0SHA.local.info 13.1-RELEASE-p3 FreeBSD 13.1-RELEASE-p3 GENERIC amd64
 
Current version of pixman: 0.42.2
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Thu Dec 22 15:16:48 2022
(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"

Thread 1 received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
0x00000008007c1dec in strcmp () from /lib/libc.so.7
(gdb) $ 

P.S. X.Org was released: 
xorg-server-21.1.5     2022-12-14
Comment 10 Gary Jennejohn 2022-12-22 16:36:36 UTC
(In reply to Sergiy from comment #9)
I hate to say this, but you'll probably have to compile
/usr/ports/x11-servers/xorg-server yourself to get debug symbols.

You could temporarily add CFLAGS+=-g to the Makefile and then run the resulting Xorg directly from the work directory *without* trying to install it, since that will just result in stripping out all the symbols.

Another option would be to add WITH_DEBUG into make.conf before newly compiling Xorg.  This will supposedly include /usr/ports/Mk/Features/debug.mk automatically, which would add the -g flag and block stripping the binary when it's installed (based on the comments in that file).  This could be a simpler approach if it really works.  But you should remove WITH_DEBUG later, I'd say.
Comment 11 Sergiy 2022-12-28 23:31:11 UTC
(In reply to Gary Jennejohn from comment #10)

Thanks for the tips.

I decided to try the first way. But first I created a special virtual machine for training on another x64 PC.
There were various try...

I downloaded the ports tree from git and tried 
with quarterly: 
Black_N # git clone https://git.FreeBSD.org/ports.git -b 2022Q4 /usr/ports 
and with HEAD: 
Black_N # git clone https://git.FreeBSD.org/ports.git /usr/ports 
But I only got compilation errors

At first I added CFLAGS+=-g to the Makefile each time.
Then created /etc/make.conf with:
WITH_DEBUG=     yes
DEBUG_FLAGS=    -g -O0

After six unsuccessful attempts to compile xorg-server with debug symbols, a miracle finally happened for the seventh time.
(After install:
# pkg install ninja meson re2c )

And quarterly branch of the ports tree:
root@debug_sys:/home/Black_N # git clone https://git.FreeBSD.org/ports.git -b 2022Q4 /usr/ports
root@debug_sys:/home/Black_N # cd /usr/ports/x11-servers/xorg-server
root@debug_sys:/usr/ports/x11-servers/xorg-server # ls -lap
total 96
drwxr-xr-x  3 root  wheel   512 28 груд. 15:07 ./
drwxr-xr-x  9 root  wheel   512 28 груд. 15:07 ../
-rw-r--r--  1 root  wheel   168 28 груд. 15:07 distinfo
drwxr-xr-x  2 root  wheel  1024 28 груд. 15:07 files/
-rw-r--r--  1 root  wheel  4034 28 груд. 15:07 Makefile
-rw-r--r--  1 root  wheel   172 28 груд. 15:07 pkg-descr-xephyr
-rw-r--r--  1 root  wheel    78 28 груд. 15:07 pkg-descr-xnest
-rw-r--r--  1 root  wheel   101 28 груд. 15:07 pkg-descr-xorg
-rw-r--r--  1 root  wheel    90 28 груд. 15:07 pkg-descr-xvfb
-rw-r--r--  1 root  wheel  1054 28 груд. 15:07 pkg-message
-rw-r--r--  1 root  wheel  4719 28 груд. 15:07 pkg-plist
root@debug_sys:/usr/ports/x11-servers/xorg-server # cat distinfo
TIMESTAMP = 1659367891
SHA256 (xorg-server-21.1.4.tar.xz) = 5cc4be8ee47edb58d4a90e603a59d56b40291ad38371b0bd2471fc3cbee1c587
SIZE (xorg-server-21.1.4.tar.xz) = 4940176

root@debug_sys:/usr/ports/x11-servers/xorg-server # make WRKDIRPREFIX=/home/Black_N/test_xorg

And as a result:
$ file /home/Black_N/test_xorg/usr/ports/x11-servers/xorg-server/work-xorg/stage/usr/local/libexec/Xorg
/home/Black_N/test_xorg/usr/ports/x11-servers/xorg-server/work-xorg/stage/usr/local/libexec/Xorg: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, with debug_info, not stripped

Then I transferred it to the Tosha using tar.

Maybe I did something wrong...
I disabled hardening again. I configured using the file in /usr/local/etc/X11/xorg.conf.d nv driver, instead of vesa, rebooted...
I got a PC without X.
I removed all Xorg.core.
Tried running:
root@T0SHA:/home/Black_N # exec /home/Black_N/test_xorg/usr/ports/x11-servers/xorg-server/work-xorg/stage/usr/local/libexec/Xorg

A new Xorg.core file is created.

I executed/got:
Script started on Wed Dec 28 23:12:05 2022
root@T0SHA:/home/Black_N # gdb -c /home/Black_N/Xorg.core
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
[New LWP 100141]
[New LWP 100142]
Core was generated by `/usr/home/Black_N/test_xorg/usr/ports/x11-servers/xorg-server/work-xorg/stage/us'.
Program terminated with signal SIGABRT, Aborted.
Sent by thr_kill() from pid 1034 and user 0.
#0  0x000000080087733a in ?? ()
[Current thread is 1 (LWP 100141)]
(gdb) bt
#0  0x000000080087733a in ?? ()
#1  0x00000008007efc74 in ?? ()
#2  0x000000000001872d in ?? ()
#3  0x149c2d2ac447088c in ?? ()
#4  0x00007fffffffdab4 in ?? ()
#5  0x00007fffffffe070 in ?? ()
#6  0x00007fffffffdad0 in ?? ()
#7  0x00000008008a1109 in ?? ()
#8  0x149c2d2ac447088c in ?? ()
#9  0x0000000000000000 in ?? ()
(gdb) exit

Before this, I also tried to run the resulting Xorg from under lldb and gdb, but when running this way, everything freezes as expected and Xorg.core is not created.
When running like this, the message in gdb disappeared (No debugging symbols found in ...)
Comment 12 Gary Jennejohn 2022-12-29 11:19:19 UTC
(In reply to Sergiy from comment #11)
Too bad.  Maybe it's failing in one of the many libraries under /usr/local which Xorg uses, which are stripped.  Just run "ldd /usr/local/bin/Xorg", or wherever Xorg is located, to see the library dependencies.  On my system the libraries under /usr/lib abd /lib are not stripped.  The ones under /usr/local/lib are all stripped.
Comment 13 Sergiy 2022-12-29 19:26:06 UTC
(In reply to Gary Jennejohn from comment #12)
All right!
But Xorg is located in /usr/local/libexec

Black_N # ldd /usr/local/libexec/Xorg
/usr/local/libexec/Xorg:
        libpixman-1.so.0 => /usr/local/lib/libpixman-1.so.0 (0x821fd4000)
        libm.so.5 => /lib/libm.so.5 (0x822d3b000)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x82381b000)
        libpciaccess.so.0 => /usr/local/lib/libpciaccess.so.0 (0x8247bc000)
        libmd.so.6 => /lib/libmd.so.6 (0x82486e000)
        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x824ea3000)
        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x8265db000)
        libXfont2.so.2 => /usr/local/lib/libXfont2.so.2 (0x825e5f000)
        libxshmfence.so.1 => /usr/local/lib/libxshmfence.so.1 (0x826d36000)
        libudev.so.0 => /usr/local/lib/libudev.so.0 (0x828437000)
        libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x8271dd000)
        libthr.so.3 => /lib/libthr.so.3 (0x827d05000)
        libxcvt.so.0 => /usr/local/lib/libxcvt.so.0 (0x828f01000)
        libc.so.7 => /lib/libc.so.7 (0x8298e0000)
        libz.so.6 => /lib/libz.so.6 (0x82a306000)
        libfontenc.so.1 => /usr/local/lib/libfontenc.so.1 (0x82af22000)
        libfreetype.so.6 => /usr/local/lib/libfreetype.so.6 (0x82bc62000)
        libdevinfo.so.6 => /usr/lib/libdevinfo.so.6 (0x82d46e000)
        libprocstat.so.1 => /usr/lib/libprocstat.so.1 (0x82be9a000)
        libbz2.so.4 => /usr/lib/libbz2.so.4 (0x82c2ae000)
        libpng16.so.16 => /usr/local/lib/libpng16.so.16 (0x82c340000)
        libbrotlidec.so.1 => /usr/local/lib/libbrotlidec.so.1 (0x82c96f000)
        libelf.so.2 => /lib/libelf.so.2 (0x82df32000)
        libkvm.so.7 => /lib/libkvm.so.7 (0x82f847000)
        libutil.so.9 => /lib/libutil.so.9 (0x82ee25000)
        libbrotlicommon.so.1 => /usr/local/lib/libbrotlicommon.so.1 (0x8309fa000)

Black_N # ldd /usr/local/bin/Xorg
ldd: /usr/local/bin/Xorg: not a dynamic ELF executable
Comment 14 Gary Jennejohn 2022-12-29 20:23:12 UTC
(In reply to Sergiy from comment #13)
Not on my system.  Everything is under /usr/local/bin, nothing Xorg related is under /usr/local/libexec.  But I'm running X Server 1.20.11, so things may have changed in newer versions.
Comment 15 Sergiy 2022-12-29 20:49:14 UTC
(In reply to Gary Jennejohn from comment #14)
Maybe I should venture on
# pkg delete xorg-server

But I will try to install from the ports what is removed along with it:

        xf86-input-keyboard: 1.9.0_5
        xf86-input-libinput: 1.2.0_1
        xf86-input-mouse: 1.9.3_4
        xf86-video-nv: 2.1.21_5
        xf86-video-scfb: 0.0.7_1
        xf86-video-vesa: 2.5.0_1
        xorg: 7.7_3
        xorg-drivers: 7.7_7
        xorg-server: 21.1.4_1,1

Before that, I'll create /etc/make.conf with 
WITH_DEBUG=     yes
DEBUG_FLAGS=    -g -O0

If there is even a small chance that it will help later.
Comment 16 Sergiy 2022-12-29 21:38:06 UTC
(In reply to Gary Jennejohn from comment #14)
I have
root@T0SHA:/home/Black_N # file /usr/local/bin/Xorg
/usr/local/bin/Xorg: POSIX shell script, ASCII text executable
root@T0SHA:/home/Black_N # cat /usr/local/bin/Xorg
#!/bin/sh
#
# Execute Xorg.wrap if it exists otherwise execute Xorg directly.
# This allows distros to put the suid wrapper in a separate package.

basedir="/usr/local/libexec"
if [ -x "$basedir"/Xorg.wrap ]; then
        exec "$basedir"/Xorg.wrap "$@"
else
        exec "$basedir"/Xorg "$@"
fi
Comment 17 Gary Jennejohn 2022-12-30 11:04:22 UTC
(In reply to Sergiy from comment #16)
Right, that's obviously due to my older Xorg version.
I tried moving /usr/local to /usr/Local and then creating an empty /usr/local so that building a fresh Xorg (with debugging in /etc/make.conf) would generate all the libraries and binaries with debugging symbols.
Unfortunately, because I already had so much installed using pkg, it was a catastrophic mess and I gave up.
So, I conclude that the only way to get the desired results would be to make a clean FreeBSD installation and then build the ports with an empty /usr/local.
There may be better ways to do that, e.g. using poudriere, but I've never used it.
Comment 18 Sergiy 2023-01-17 22:37:43 UTC
(In reply to Gary Jennejohn from comment #17)
I tried a clean install (FreeBSD-13.1-RELEASE-amd64-dvd1.iso) on Tosha on another HDD. When installing the system, I turned on including: 
 base-dbg
 kernel-dbg
 lib32-dbg
 lib32
 src
Turned off hardening.

# freebsd-update fetch
# freebsd-update install

Rebooting

# freebsd-version -urk
13.1-RELEASE-p3
13.1-RELEASE-p3
13.1-RELEASE-p5

I downloaded the ports tree from git:
Black_N # git clone https://git.FreeBSD.org/ports.git -b 2023Q1 /usr/ports

I created /etc/make.conf with:
WITH_DEBUG=     yes
DEBUG_FLAGS=    -g -O0

I built and installed from ports:
# cd /usr/ports/x11-servers/xorg-server 
# make install clean
...
# cd /usr/ports/x11-drivers/xf86-video-nv
# make install clean
...
# cd /usr/ports/x11/xorg
# make install clean
...

Checked the file /usr/local/libexec/Xorg
...with debug_info, not stripped

Rebooting and
# startx

Error and create Xorg.core

root@T0sha_db:/home/Black_N # gdb -c Xorg.core
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
[New LWP 100141]
[New LWP 100143]
Core was generated by `/usr/local/libexec/Xorg :0 -auth /root/.serverauth.984'.
Program terminated with signal SIGABRT, Aborted.
Sent by thr_kill() from pid 997 and user 0.
#0  0x0000000800be433a in ?? ()
[Current thread is 1 (LWP 100141)]
(gdb) bt
#0  0x0000000800be433a in ?? ()
#1  0x0000000800b5cc74 in ?? ()
#2  0x000000000001872d in ?? ()
#3  0x3e8ea16c7145a22c in ?? ()
#4  0x00007fffffffda44 in ?? ()
#5  0x00007fffffffe000 in ?? ()
#6  0x00007fffffffda60 in ?? ()
#7  0x0000000800c0e109 in ?? ()
#8  0x3e8ea16c7145a22c in ?? ()
#9  0x0000000000000000 in ?? ()
(gdb) exit
root@T0sha_db:/home/Black_N # exit

Script done on Tue Jan 17 23:23:01 2023

root@T0sha_db:/home/Black_N # lldb -c Xorg.core
(lldb) target create --core "Xorg.core"
Core file '/home/Black_N/Xorg.core' (x86_64) was loaded.
(lldb) bt
* thread #1, name = 'Xorg', stop reason = signal SIGABRT
  * frame #0: 0x0000000800be433a
    frame #1: 0x0000000800b5cc74
(lldb) q

I don't understand what I did wrong?
Comment 19 Sergiy 2023-01-17 23:12:23 UTC
Created attachment 239546 [details]
Tosha_db_Xorg.log
Comment 20 Sergiy 2023-01-18 10:53:28 UTC
(In reply to Sergiy from comment #19)
Sorry...
I tried again (actually, I already lost count)
But this time I got something.

$ cat 20230118_gdb_trivial_ns_XorgCore.txt
Script started on Wed Jan 18 12:33:45 2023
root@T0sha_db:/home/Black_N # gdb -c /home/Black_N/Xorg.core /usr/local/libexec/Xorg
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/libexec/Xorg...
[New LWP 100136]
[New LWP 100137]

warning: Could not load shared library symbols for [vdso].
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/usr/local/libexec/Xorg :0 -auth /root/.serverauth.952'.
Program terminated with signal SIGABRT, Aborted.
Sent by thr_kill() from pid 965 and user 0.
#0  thr_kill () at thr_kill.S:4
4       thr_kill.S: No such file or directory.
[Current thread is 1 (LWP 100136)]
(gdb) bt full
#0  thr_kill () at thr_kill.S:4
No locals.
#1  0x0000000800b5cc74 in __raise (s=s@entry=6)
    at /usr/src/lib/libc/gen/raise.c:52
        id = 100136
#2  0x0000000800c0e109 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
        act = {__sigaction_u = {__sa_handler = 0x0, __sa_sigaction = 0x0}, 
          sa_flags = 4558896, sa_mask = {__bits = {4294967263, 4294967295, 
              4294967295, 4294967295}}}
#3  0x000000000045c82c in OsAbort () at ../os/utils.c:1352
No locals.
#4  0x0000000000466ea6 in AbortServer () at ../os/log.c:879
No locals.
#5  0x00000000004649c7 in FatalError (
    f=0x239f21 "Caught signal %d (%s). Server aborting\n") at ../os/log.c:1017
        beenhere = 1
        args = {{gp_offset = 24, fp_offset = 48, 
            overflow_arg_area = 0x7fffffffdb90, 
            reg_save_area = 0x7fffffffda90}}
        args2 = {{gp_offset = 8, fp_offset = 48, 
            overflow_arg_area = 0x7fffffffdb90, 
            reg_save_area = 0x7fffffffda90}}
#6  0x0000000000459143 in OsSigHandler (signo=11, sip=0x7fffffffe370, 
    unused=0x7fffffffe000) at ../os/osinit.c:156
No locals.
#7  0x0000000800a9458e in handle_signal (actp=actp@entry=0x7fffffffdf80, 
    sig=sig@entry=11, info=info@entry=0x7fffffffe370, 
    ucp=ucp@entry=0x7fffffffe000) at /usr/src/lib/libthr/thread/thr_sig.c:301
        uc2 = {uc_sigmask = {__bits = {0, 4294967295, 0, 0}}, uc_mcontext = {
--Type <RET> for more, q to quit, c to continue without paging--c
            mc_onstack = 0, mc_rdi = 0, mc_rsi = 34380784320, mc_rdx = 140737488345056, mc_rcx = 206158430216, mc_r8 = 140737488348416, mc_r9 = 140737488348176, mc_rax = 1024, mc_rbx = 0, mc_rbp = 34372941504, mc_r10 = 0, mc_r11 = 0, mc_r12 = 0, mc_r13 = 140737488345136, mc_r14 = 4398046511104, mc_r15 = 196616, mc_trapno = 4294957104, mc_fs = 32767, mc_gs = 0, mc_addr = 1024, mc_flags = 0, mc_es = 0, mc_ds = 0, mc_err = 34372941504, mc_rip = 0, mc_cs = 0, mc_rflags = 0, mc_rsp = 34372093968, mc_ss = 0, mc_len = 0, mc_fpformat = 0, mc_ownedfp = 0, mc_fpstate = {0, 0, 0, 0, 0, 0, -4294967296, 0, 0, 0, 34380784320, 34377306376, 140737488346496, 34370814698, 0, 0, 0, 0, 0, 34380784320, 0, 140737488346544, 34372880472, 34372985456, 140737488346848, 2309997, 140737488346528, 34370785888, 34372874032, 13, 140737488346656, 34372098038, 0, 34372094608, 34372941504, 0, 34380784320, 34377306376, 140737488346704, 34370814698, 75, 140737488347040, 140737488347040, 140737488346768, 0, 34380784320, 4294958864, 140737488346784, 1, 1, 75, 34372941504, 140737488346736, 34370785888, 34372874032, 75, 140737488346896, 34372076895, 140737488347040, 75, 140737488346752, 1, 0, 34372094608}, mc_fsbase = 34372941504, mc_gsbase = 0, mc_xfpustate = 0, mc_xfpustate_len = 71776119061217280, mc_spare = {1, 0, -7343771073370828094, 0}}, uc_link = 0x200, uc_stack = {ss_sp = 0xff0, ss_size = 4096, ss_flags = 128}, uc_flags = -8368, __spare__ = {32767, 4609518, 0, 75}}
        curthread = 0x801412000
        in_sigsuspend = 0
        cancel_enable = 1
        cancel_point = 0
        sigfunc = 0x0
        err = <optimized out>
        cancel_async = <optimized out>
#8  0x0000000800a93b3f in thr_sighandler (sig=11, info=0x7fffffffe370, _ucp=0x7fffffffe000) at /usr/src/lib/libthr/thread/thr_sig.c:246
        act = {__sigaction_u = {__sa_handler = 0x459030 <OsSigHandler>, __sa_sigaction = 0x459030 <OsSigHandler>}, sa_flags = 64, sa_mask = {__bits = {1024, 0, 0, 0}}}
        err = <optimized out>
        curthread = 0x801412000
        ucp = <optimized out>
        usa = <optimized out>
#9  <signal handler called>
No symbol table info available.
#10 strcmp () at /usr/src/lib/libc/amd64/string/strcmp.S:46
No locals.
#11 0x000000000049b5ad in xf86LookupMode (scrp=0x8014e6f00, modep=0x801541d00, clockRanges=0x801453450, strategy=LOOKUP_BEST_REFRESH) at ../hw/xfree86/common/xf86Mode.c:511
        type = 64
        p = 0x801541c40
        bestMode = 0x0
        cp = 0x0
        i = 0
        k = 0
        gap = 0
        minimumGap = 2001
        refresh = 2.3860490291416954e-317
        bestRefresh = 0
        found = 0
        extraFlags = 0
        clockIndex = -1
        MulFactor = 1
        DivFactor = 1
        ModePrivFlags = 0
        status = MODE_NOMODE
        allowDiv2 = 0
        n = 5
        types = {9, 1, 40, 32, 72, 64, 0}
        ntypes = 7
#12 0x0000000000499b13 in xf86ValidateModes (scrp=0x8014e6f00, availModes=0x8014dc000, modeNames=0x801408108, clockRanges=0x801453450, linePitches=0x0, minPitch=256, maxPitch=4080, pitchInc=512, minHeight=128, maxHeight=4096, virtualX=0, virtualY=0, apertureSize=267845632, strategy=LOOKUP_BEST_REFRESH) at ../hw/xfree86/common/xf86Mode.c:1719
        repeat = 0
        p = 0x801541d00
        q = 0x0
        r = 0x801541b80
        new = 0x801541c40
        last = 0x801541d00
        endp = 0x801541d08
        i = 0
        numModes = 0
        status = MODE_OK
        linePitch = -1
        virtX = 0
        virtY = 0
        newLinePitch = 8
        newVirtX = 17479688
        newVirtY = 8
        modeSize = 1024000
        validateAllDefaultModes = 1
        userModes = 0
        saveType = 32
        BankFormat = 0x8014e6f50
        cp = 0x0
        numTimings = 0
        hsync = {{hi = -nan(0x7fe8a0), lo = 4.59163468e-41}, {hi = 7.55337567e-39, lo = 1.12103877e-44}, {hi = 0, lo = 0}, {hi = 0, lo = 0}, {hi = 3.58732407e-43, lo = 0}, {hi = 0, lo = 0}, {hi = 3.7915863e-38, lo = 1.12103877e-44}, {hi = 3.77903067e-38, lo = 1.12103877e-44}}
        vrefresh = {{hi = 6.75217347e-39, lo = 0}, {hi = 3.07550261e-39, lo = 0}, {hi = 4.64124064e-41, lo = 0}, {hi = 5.73971851e-42, lo = 0}, {hi = -nan(0x7fea40), lo = 4.59163468e-41}, {hi = 0, lo = 0}, {hi = 5.71729773e-42, lo = 0}, {hi = 5.60519386e-45, lo = 0}}
        inferred_virtual = 0
#13 0x0000000801ce73ca in NVPreInit (pScrn=0x8014e6f00, flags=0) at nv_driver.c:1975
        pNv = 0x801462800
        from = X_PROBED
        i = 17449632
        max_width = 4080
        max_height = 4096
        clockRanges = 0x801453450
        s = 0x0
        config_mon_rates = 0
#14 0x0000000000482fcd in InitOutput (pScreenInfo=0x546e88 <screenInfo>, argc=4, argv=0x7fffffffea48) at ../hw/xfree86/common/xf86Init.c:478
        i = 0
        j = 0
        k = 0
        scr_index = 0
        modulelist = 0x0
        optionlist = 0x801426730
        autoconfig = 0
        sigio_blocked = 0
        want_hw_access = 1
        configured_device = 0x0
#15 0x00000000002f876a in dix_main (argc=4, argv=0x7fffffffea48, envp=0x7fffffffea70) at ../dix/main.c:190
        i = 256
        alwaysCheckForInput = {0, 1}
#16 0x000000000050994a in main (argc=4, argv=0x7fffffffea48, envp=0x7fffffffea70) at ../dix/stubmain.c:34
No locals.
(gdb) exit
root@T0sha_db:/home/Black_N # exit

Script done on Wed Jan 18 12:37:06 2023

I hope my efforts are not in vain.
Comment 21 Gary Jennejohn 2023-01-18 13:20:33 UTC
(In reply to Sergiy from comment #19)
Well, looking at the latest Xorg.log it seems that the nv driver works as intended.  The basic problem is that the driver can't find a suitable value for hsync and vrefresh and, as a result, has to abort.
Looking at the values in stack 12 in post 20 it's obvious that the hsync and vrefresh values are ridiculously small.
Apparently you don't have a xorg.conf with a Monitor section and the driver is making a wild guess about the suitable clocks.
If you have the hsync and vrefresh information for your screen then you should definitely add a Monitor section!
As an example, this is what I have in my xorg.conf:

Section "Monitor"
Identifier      "BenQ"
HorizSync       31.5 - 82.0
VertRefresh     50.0 - 90.0
EndSection

Section "Device"
    Identifier     "GeForce1050Ti"
    Driver         "nvidia"
EndSection

Section "Screen"
    Identifier     "Screen 1"
    Device         "GeForce1050Ti"
    Monitor        "BenQ"
    DefaultDepth    24
EndSection
Comment 22 Sergiy 2023-01-18 16:17:18 UTC
(In reply to Gary Jennejohn from comment #21)
Yes.
I paid attention to this at the very beginning of my journey, even before the messages here.
I tried to solve this and created the following files on T0sha (not T0sha_db) in /usr/local/etc/X11/xorg.conf.d/:

monitor0-freq.conf
Section "Monitor"
	Identifier   "Monitor0"
	HorizSync    29.37-49.31   # kHz
	VertRefresh  56.00-59.91   # Hz
EndSection

screen-resolution.conf
Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	SubSection "Display"
	Modes      "1280x800"
	EndSubSection
EndSection

for drivers:
- for testing nv
driver-nv.conf
Section "Device"
	Identifier "Card0"
	Driver     "nv"
	# BusID    "PCI1:0:0"
EndSection

- and working vesa
driver-vesa.conf
Section "Device"
	Identifier "Card0"
	Driver     "vesa"
	# BusID    "PCI1:0:0"
EndSection

I took the data for monitor0-freq.conf from the Xorg.0.log file of the working vesa driver.

But this did not lead to the desired result on T0sha.

Later, I will try to create the appropriate files on T0sha_db and report the results.

Thanks.
Comment 23 Gary Jennejohn 2023-01-18 17:23:20 UTC
(In reply to Sergiy from comment #22)
Yes, but you don't have a Monitor entry in Screen, so Xorg doesn't know what the correct HorizSync and VertRefresh frequencies are.
Comment 24 Sergiy 2023-01-18 19:02:26 UTC
(In reply to Gary Jennejohn from comment #23)
Okay! 
If I understand correctly, I did this on T0sha_db:
/usr/local/etc/X11/xorg.conf.d/
I created files:

monitor0-freq.conf
Section "Monitor"
	Identifier   "Monitor0"
	HorizSync    29.37-49.31   # kHz
	VertRefresh  56.00-59.91   # Hz
EndSection

and

screen-resolution.conf
Section "Screen"
	Identifier   "Screen0"
	Device       "Card0"
	Monitor      "Monitor0"
	DefaultDepth 24
	SubSection "Display"
		Viewport 0 0
		Depth    24
		Modes    "1280x800"
	EndSubSection
EndSection

The result is the same, although now in Xorg.0.log:
...
[   154.128] (II) NV(0): Monitor0: Using hsync range of 29.37-49.31 kHz
[   154.128] (II) NV(0): Monitor0: Using vrefresh range of 56.00-59.91 Hz
...

and gdb

Script started on Wed Jan 18 19:48:11 2023
Xorg@T0sha_db:/home/Black_N # gdb -c /home/Black_N/Xorg.core /usr/local/libexec/ 
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/libexec/Xorg...
[New LWP 100141]
[New LWP 100142]

warning: Could not load shared library symbols for [vdso].
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/usr/local/libexec/Xorg :0 -auth /root/.serverauth.957'.
Program terminated with signal SIGABRT, Aborted.
Sent by thr_kill() from pid 970 and user 0.
#0  thr_kill () at thr_kill.S:4
4       thr_kill.S: No such file or directory.
[Current thread is 1 (LWP 100141)]
(gdb) bt full
#0  thr_kill () at thr_kill.S:4
No locals.
#1  0x0000000800b5cc74 in __raise (s=s@entry=6)
    at /usr/src/lib/libc/gen/raise.c:52
        id = 100141
#2  0x0000000800c0e109 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
        act = {__sigaction_u = {__sa_handler = 0x0, __sa_sigaction = 0x0}, 
          sa_flags = 4558896, sa_mask = {__bits = {4294967263, 4294967295, 
              4294967295, 4294967295}}}
#3  0x000000000045c82c in OsAbort () at ../os/utils.c:1352
No locals.
#4  0x0000000000466ea6 in AbortServer () at ../os/log.c:879
No locals.
#5  0x00000000004649c7 in FatalError (
    f=0x239f21 "Caught signal %d (%s). Server aborting\n") at ../os/log.c:1017
        beenhere = 1
        args = {{gp_offset = 24, fp_offset = 48, 
            overflow_arg_area = 0x7fffffffdb90, 
            reg_save_area = 0x7fffffffda90}}
        args2 = {{gp_offset = 8, fp_offset = 48, 
            overflow_arg_area = 0x7fffffffdb90, 
            reg_save_area = 0x7fffffffda90}}
#6  0x0000000000459143 in OsSigHandler (signo=11, sip=0x7fffffffe370, 
    unused=0x7fffffffe000) at ../os/osinit.c:156
No locals.
#7  0x0000000800a9458e in handle_signal (actp=actp@entry=0x7fffffffdf80, 
    sig=sig@entry=11, info=info@entry=0x7fffffffe370, 
    ucp=ucp@entry=0x7fffffffe000) at /usr/src/lib/libthr/thread/thr_sig.c:301
        uc2 = {uc_sigmask = {__bits = {0, 4294967295, 0, 0}}, uc_mcontext = {
--Type <RET> for more, q to quit, c to continue without paging--c
            mc_onstack = 0, mc_rdi = 0, mc_rsi = 34380784320, mc_rdx = 140737488345056, mc_rcx = 206158430216, mc_r8 = 140737488348416, mc_r9 = 140737488348176, mc_rax = 1024, mc_rbx = 0, mc_rbp = 34372941504, mc_r10 = 0, mc_r11 = 0, mc_r12 = 0, mc_r13 = 140737488345136, mc_r14 = 4398046511104, mc_r15 = 196616, mc_trapno = 4294957104, mc_fs = 32767, mc_gs = 0, mc_addr = 1024, mc_flags = 0, mc_es = 0, mc_ds = 0, mc_err = 34372941504, mc_rip = 0, mc_cs = 0, mc_rflags = 0, mc_rsp = 34372093968, mc_ss = 0, mc_len = 0, mc_fpformat = 0, mc_ownedfp = 0, mc_fpstate = {0, 0, 0, 0, 0, 0, -4294967296, 0, 0, 0, 34380784320, 34377306376, 140737488346496, 34370814698, 0, 0, 0, 0, 0, 34380784320, 0, 140737488346544, 34372880472, 34372985456, 140737488346848, 2309997, 140737488346528, 34370785888, 34372874032, 13, 140737488346656, 34372098038, 0, 34372094608, 34372941504, 0, 34380784320, 34377306376, 140737488346704, 34370814698, 66, 140737488347040, 140737488347040, 140737488346768, 0, 34380784320, 4294958864, 140737488346784, 1, 1, 66, 34372941504, 140737488346736, 34370785888, 34372874032, 66, 140737488346896, 34372076895, 140737488347040, 66, 140737488346752, 1, 0, 34372094608}, mc_fsbase = 34372941504, mc_gsbase = 0, mc_xfpustate = 0, mc_xfpustate_len = 71776119061217280, mc_spare = {1, 0, 1631945823472715058, 0}}, uc_link = 0x200, uc_stack = {ss_sp = 0xff0, ss_size = 4096, ss_flags = 128}, uc_flags = -8368, __spare__ = {32767, 4609518, 0, 66}}
        curthread = 0x801412000
        in_sigsuspend = 0
        cancel_enable = 1
        cancel_point = 0
        sigfunc = 0x0
        err = <optimized out>
        cancel_async = <optimized out>
#8  0x0000000800a93b3f in thr_sighandler (sig=11, info=0x7fffffffe370, _ucp=0x7fffffffe000) at /usr/src/lib/libthr/thread/thr_sig.c:246
        act = {__sigaction_u = {__sa_handler = 0x459030 <OsSigHandler>, __sa_sigaction = 0x459030 <OsSigHandler>}, sa_flags = 64, sa_mask = {__bits = {1024, 0, 0, 0}}}
        err = <optimized out>
        curthread = 0x801412000
        ucp = <optimized out>
        usa = <optimized out>
#9  <signal handler called>
No symbol table info available.
#10 strcmp () at /usr/src/lib/libc/amd64/string/strcmp.S:46
No locals.
#11 0x000000000049b5ad in xf86LookupMode (scrp=0x8014e7e00, modep=0x801553b80, clockRanges=0x801453450, strategy=LOOKUP_BEST_REFRESH) at ../hw/xfree86/common/xf86Mode.c:511
        type = 64
        p = 0x801553ac0
        bestMode = 0x0
        cp = 0x0
        i = 0
        k = 0
        gap = 0
        minimumGap = 2001
        refresh = 2.3860490291416954e-317
        bestRefresh = 0
        found = 0
        extraFlags = 0
        clockIndex = -1
        MulFactor = 1
        DivFactor = 1
        ModePrivFlags = 0
        status = MODE_NOMODE
        allowDiv2 = 0
        n = 5
        types = {9, 1, 40, 32, 72, 64, 0}
        ntypes = 7
#12 0x0000000000499b13 in xf86ValidateModes (scrp=0x8014e7e00, availModes=0x8014dc0c0, modeNames=0x801426730, clockRanges=0x801453450, linePitches=0x0, minPitch=256, maxPitch=4080, pitchInc=512, minHeight=128, maxHeight=4096, virtualX=0, virtualY=0, apertureSize=267845632, strategy=LOOKUP_BEST_REFRESH) at ../hw/xfree86/common/xf86Mode.c:1719
        repeat = 0
        p = 0x801553b80
        q = 0x801553ac0
        r = 0x6a8
        new = 0x801553b80
        last = 0x801553b80
        endp = 0x801553b88
        i = 1
        numModes = 0
        status = MODE_OK
        linePitch = -1
        virtX = 0
        virtY = 0
        newLinePitch = 8
        newVirtX = 17479688
        newVirtY = 8
        modeSize = 30250512
        validateAllDefaultModes = 1
        userModes = 1
        saveType = 32
        BankFormat = 0x8014e7e50
        cp = 0x0
        numTimings = 0
        hsync = {{hi = -nan(0x7fe8a0), lo = 4.59163468e-41}, {hi = 7.55337567e-39, lo = 1.12103877e-44}, {hi = 0, lo = 0}, {hi = 0, lo = 0}, {hi = 3.58732407e-43, lo = 0}, {hi = 0, lo = 0}, {hi = 3.7926625e-38, lo = 1.12103877e-44}, {hi = 3.77908448e-38, lo = 1.12103877e-44}}
        vrefresh = {{hi = 6.75217347e-39, lo = 0}, {hi = 3.07550261e-39, lo = 0}, {hi = 4.64124064e-41, lo = 0}, {hi = 5.73971851e-42, lo = 0}, {hi = -nan(0x7fea40), lo = 4.59163468e-41}, {hi = 0, lo = 0}, {hi = 5.71729773e-42, lo = 0}, {hi = 5.60519386e-45, lo = 0}}
        inferred_virtual = 0
#13 0x0000000801ce73ca in NVPreInit (pScrn=0x8014e7e00, flags=0) at nv_driver.c:1975
        pNv = 0x801462800
        from = X_PROBED
        i = 17449632
        max_width = 4080
        max_height = 4096
        clockRanges = 0x801453450
        s = 0x0
        config_mon_rates = 1
#14 0x0000000000482fcd in InitOutput (pScreenInfo=0x546e88 <screenInfo>, argc=4, argv=0x7fffffffea48) at ../hw/xfree86/common/xf86Init.c:478
        i = 0
        j = 0
        k = 0
        scr_index = 0
        modulelist = 0x0
        optionlist = 0x801426770
        autoconfig = 0
        sigio_blocked = 0
        want_hw_access = 1
        configured_device = 0x0
#15 0x00000000002f876a in dix_main (argc=4, argv=0x7fffffffea48, envp=0x7fffffffea70) at ../dix/main.c:190
        i = 256
        alwaysCheckForInput = {0, 1}
#16 0x000000000050994a in main (argc=4, argv=0x7fffffffea48, envp=0x7fffffffea70) at ../dix/stubmain.c:34
No locals.
(gdb) exit
root@T0sha_db:/home/Black_N # exit

Script done on Wed Jan 18 19:48:54 2023
Comment 25 Sergiy 2023-01-18 19:18:31 UTC
lldb

Script started on Wed Jan 18 20:08:27 2023
/XorgT0sha_db:/home/Black_N # lldb -c /home/Black_N/Xorg.core /usr/local/libexec 
(lldb) target create "/usr/local/libexec/Xorg" --core "/home/Black_N/Xorg.core"
Core file '/home/Black_N/Xorg.core' (x86_64) was loaded.
(lldb) bt
This version of LLDB has no plugin for the language "assembler". Inspection of frame variables will be limited.
* thread #1, name = 'Xorg', stop reason = signal SIGABRT
  * frame #0: 0x0000000800be433a libc.so.7`__sys_thr_kill at thr_kill.S:4
    frame #1: 0x0000000800b5cc74 libc.so.7`__raise(s=6) at raise.c:52:10
    frame #2: 0x0000000800c0e109 libc.so.7`abort at abort.c:67:8
    frame #3: 0x000000000045c82c Xorg`OsAbort at utils.c:1352:5
    frame #4: 0x0000000000466ea6 Xorg`AbortServer at log.c:879:9
    frame #5: 0x00000000004649c7 Xorg`FatalError(f="") at log.c:1017:9
    frame #6: 0x0000000000459143 Xorg`OsSigHandler(signo=11, sip=0x00007fffffffe370, unused=0x00007fffffffe000) at osinit.c:156:5
    frame #7: 0x0000000800a9458e libthr.so.3`handle_signal(actp=0x00007fffffffdf80, sig=11, info=0x00007fffffffe370, ucp=0x00007fffffffe000) at thr_sig.c:301:3
    frame #8: 0x0000000800a93b3f libthr.so.3`thr_sighandler(sig=11, info=0x00007fffffffe370, _ucp=0x00007fffffffe000) at thr_sig.c:246:2
    frame #9: 0x00007ffffffff8a3 [vdso]
    frame #10: 0x0000000000499b13 Xorg`xf86ValidateModes(scrp=0x00000008014e7e00, availModes=0x00000008014dc0c0, modeNames=0x0000000801426730, clockRanges=0x0000000801453450, linePitches=0x0000000000000000, minPitch=256, maxPitch=4080, pitchInc=512, minHeight=128, maxHeight=4096, virtualX=0, virtualY=0, apertureSize=267845632, strategy=LOOKUP_BEST_REFRESH) at xf86Mode.c:1719:18
    frame #11: 0x0000000801ce73ca nv_drv.so`NVPreInit(pScrn=0x00000008014e7e00, flags=0) at nv_driver.c:1975:13
    frame #12: 0x0000000000482fcd Xorg`InitOutput(pScreenInfo=0x0000000000546e88, argc=4, argv=0x00007fffffffea48) at xf86Init.c:478:17
    frame #13: 0x00000000002f876a Xorg`dix_main(argc=4, argv=0x00007fffffffea48, envp=0x00007fffffffea70) at main.c:190:9
    frame #14: 0x000000000050994a Xorg`main(argc=4, argv=0x00007fffffffea48, envp=0x00007fffffffea70) at stubmain.c:34:12
    frame #15: 0x000000000029df80 Xorg`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1_c.c:75:7
(lldb) q
root@T0sha_db:/home/Black_N # exit

Script done on Wed Jan 18 20:08:42 2023
Comment 26 Gary Jennejohn 2023-01-20 17:40:09 UTC
(In reply to Sergiy from comment #25)
NetBSD supports the nouveau driver, which is being activley maintained, since it's included in Linux distributions.  It replaces the old nv driver.
If you feel adventurous then you might try installing NetBSD.  Here's a link from the nouveau website which could be useful:
https://nouveau.freedesktop.org/NetBSD.html
Comment 27 Sergiy 2023-01-20 22:35:44 UTC
(In reply to Gary Jennejohn from comment #26)
Thanks for the info. 
I heard about it. Maybe my eyes will get tired of vesa (1024x768) and I will dare.
With little hope I am waiting for xorg-server-21.1.6 (Bug 268963), maybe something will be broken there and nv will work again for me.
This worked fine before (starting with FreeBSD 12.1 ..., then FreeBSD 13... until update xorg-server: 1.20.14,1 -> 21.1.4_1,1 and xf86-video-nv: 2.1.21_4 -> 2.1.21_5, and as I understand, the problem arose not only with me).
Even earlier, nvidia-driver-304 worked. On the nVidia website I also found the 334.21 driver for FreeBSD with Quadro NVS 110M support, but it seems to have died before 304.

If you look at the chronology X.org:
xf86-video-nv-2.1.21 — 2017-01-17
...
xorg-server-21.1.4 — 2022-07-12
xf86-video-nv-2.1.22 — 2022-07-27

Perhaps after xorg-server-21.1.6 it will be the turn of xf86-video-nv-2.1.22.

Thanks.
Comment 28 Gary Jennejohn 2023-01-21 09:12:06 UTC
(In reply to Sergiy from comment #27)
I still have a backup of /var/cache/pkg which has everything needed to install xorg-server-1.20.11_3,1, which is what I'm currently using.  This older xserver would probably work with nv.
But there are lots of other files in there and the directory is 3.5GB in size.
Perhaps you still have xserver-1.20.14,1 and all the other binaries which it uses under /var/cache/pkg, which you could simply install directly from that directory.
Better to have a working xserver than a newer one which does not work.
Comment 29 Sergiy 2023-01-22 22:34:14 UTC
(In reply to Gary Jennejohn from comment #28)
Yes, I was thinking about going back.
My /var/cache/pkg on Tosha didn't save the older xorg-server...
I have /var as a separate partition (6GB) and it cleaned often... That's something I'll have to consider in the future.
It is theoretically possible to find an older xorg-server in the ports tree on git.FreeBSD.org, for example -b 2022Q3 — xorg-server-1.20.14.tar... And create the appropriate pkgs and perform their locking...
Although mixing old and new is maybe not very good.

Tried running X with vesa driver on Tosha_db to get Xorg.log and compare it with Tosha's Xorg.log. There are certain differences,
Entries that litter the log appear:
...
halt_sys: file ../hw/xfree86/x86emu/ops.c, line 10469
halted
...
Maybe something is missing when installing from the ports, it was my mistake, it was necessary to check on vesa from the very beginning.
There are also entries that litter the log file:
...
input-thread: InputThreadDoWork waiting for devices
...
Although when startx starts TWM window manager and it works fine.


I tried to build the xf86-video-nv-2.1.22 driver and the make was successful, although I may have created some kind of “frankenstein” without knowing what I was doing...
I looked at the various version histories (git.FreeBSD.org, and X.org)
I took the Tosha_db files from the directory as a basis
/usr/ports/x11-drivers/xf86-video-nv

I copied them into xf86-video-nv-devel.
And there I edited the files:

distinfo
TIMESTAMP = 1484715801
I left it unchanged because he will quarrel later
SHA256 (xorg/driver/xf86-video-nv-2.1.22.tar.bz2) = 8a855f9a774ad28efc2e54177c05ecf7a2c8ea3380dbf9a80947fca56bb55fa7
With this entry, there is a peculiarity that X.org abandoned .bz2 compression for version xf86-video-nv-2.1.22 in favor of .xz.
First I pointed out
SHA256 (xf86-video-nv-2.1.22.tar.xz) = 6218932db5c389878d853b11b8fbb667c321b65276f55aa6842a56fb1a30d288
but when creating it, for some reason it wanted .bz2, although it may have seemed to me.
So I created the archive xf86-video-nv-2.1.22.tar.bz2. So that it is not searched for when building on X.org, I put it in /usr/ports/distfiles/xorg/driver/
SIZE (xorg/driver/xf86-video-nv-2.1.21.tar.bz2) = 354708
accordingly its size

in Makefile changed only
PORTVERSION= 2.1.22
...
removed the installed driver
# cd /usr/ports/x11-drivers/xf86-video-nv
# make uninstall

then moved the contents of xf86-video-nv-devel to /usr/ports/x11-drivers/xf86-video-nv.

Tested beforehand
# /usr/ports/x11-drivers/xf86-video-nv # make WRKDIRPREFIX=/home/Black_N/test_nv

And
# cd /usr/ports/x11-drivers/xf86-video-nv
# make install clean

But the miracle did not happen... The behavior is the same
Startx creation of Xorg.core.
Maybe I did something wrong...
Xorg.log scripts gdb lldb bt Xorg.core files are available but are they useful here? After all, they are not very relevant to the topic.
Comment 30 Gary Jennejohn 2023-01-23 11:23:39 UTC
(In reply to Sergiy from comment #29)
I just updated my /usr/ports (FreeBSD-14).  The patch files under /usr/ports/x11-drivers/xf86-video-nv/files are from September 21, 2021.  The original nv_driver.c is from 2017.  I conclude that nv_driver.c is not keeping pace with changes in xorg-server.
You're using 13.x, if I remember correctly.
This pkg repo https://pkg.freebsd.org/FreeBSD:13:amd64/ has sub-directories release_0 and release_1.  The packagesite.txz files located under these have
xorg-server","origin":"x11-servers/xorg-server","version":"1.20.9_1,1"
under release_0 and
"name":"xorg-server","origin":"x11-servers/xorg-server","version":"1.20.14,1"
under release_1 listed as being available.
I imagine that one of these older versions should work with nv.
Looking at pkg.conf(5) it looks like you could point pkg at this repository and install an older xserver from there after removing all the xorg stuff now present.
Comment 31 Sergiy 2023-01-23 22:10:53 UTC
(In reply to Gary Jennejohn from comment #30)
Thank you very much!
It worked.
I tried the following on T0sha:
temporarily modified the etc/pkg/FreeBSD.conf file:
...
   url: "pkg+http://pkg.FreeBSD.org/${ABI}/release_1",
...

I then did a selective download of the older xorg-server with all dependencies to /var/cache/pkg

# pkg fetch -d xorg-server xf86-video-nv slim slim-themes xf86-input-keyboard xf86-input-libinput xf86-input-mouse xf86-video-scfb xf86-video-vesa xorg xorg-drivers

I've also included packages that are suggested to be removed at runtime
# pkg delete xorg-server
In my case it is (on Tosha):
         slim: 1.3.6_22
         slim-themes: 1.0.1_2
         xf86-input-keyboard: 1.9.0_5
         xf86-input-libinput: 1.2.0_1
         xf86-input-mouse: 1.9.3_4
         xf86-video-nv: 2.1.21_5
         xf86-video-scfb: 0.0.7_1
         xf86-video-vesa: 2.5.0_1
         xorg: 7.7_3
         xorg-drivers: 7.7_7
         xorg-server: 21.1.4_1,1

Then I reinstalled the packages from the cache by executing
# pkg install -f slim slim-themes xf86-input-keyboard xf86-input-libinput xf86-input-mouse xf86-video-nv xf86-video-scfb xf86-video-vesa xorg xorg-drivers xorg-server
Packages were downgraded.

After a reboot, xorg-server 1.20.14,1 and xf86-video-nv 2.1.21_4 worked perfectly and my eyes appreciated the difference.

Blocked packages just in case:
# pkg lock xf86-input-keyboard xf86-input-libinput xf86
-input-mouse xf86-video-nv xf86-video-scfb xf86-video-vesa xorg xorg-drivers xorg-server

Then I switched back to quarterly in etc/pkg/FreeBSD.conf.

I hope it will work for a while.

Thank you, special thanks from my eyes.
Comment 32 Gary Jennejohn 2023-01-24 08:03:36 UTC
(In reply to Sergiy from comment #31)
Good!  I'm glad it worked.  I doubt that NV will be updated, so you'll very probably have to continue using the older xorg-server.  You took all the correct actions to make sure it won't be updated.
Comment 33 Sergiy 2023-04-15 19:52:30 UTC
For information.
Update to 2023Q2:
pkg: 1.19.0 -> 1.19.1_1
...
with the pkg update broke the ability to use the old xorg-server-1.20.14,1 + xf86-video-nv-2.1.21_4 (workaround). So I unlocked the packages mentioned above and did a full update including:

xorg-server: 1.20.14,1 -> 21.1.7,1
xf86-video-nv: 2.1.21_4 -> 2.1.21_5
xf86-video-vesa: 2.5.0 -> 2.5.0_2
...

As expected, xorg-server-21.1.7,1 + xf86-video-nv-2.1.21_5 doesn't work for me.

I use xorg-server-21.1.7,1 + xf86-video-vesa-2.5.0_2.

Perhaps the information will be useful...

I see: (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270509) and (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270869) possibly a suggested  update xf86-video-nv 2.1.22 can solve this bug.
Comment 34 Sergiy 2023-04-28 09:11:16 UTC
(In reply to Sergiy from comment #33)
The miracle did not happen...
I switched to the latest pkg branch to try:
xorg-server 21.1.8,1 + xf86-video-nv 2.1.22

I did:
# pkg update -f
# pkg upgrade -f

But unfortunately this did not solve my problem yet...
Comment 35 Huskers 2023-06-09 00:47:13 UTC
I have also locked my updates to xorg-server and xf86-video-nv. The new versions don't recognize my monitor and cause segmentation fault.
Comment 36 Sergiy 2024-01-07 15:32:42 UTC
For information.

Xorg-server + xf86-video-nv still not working after updates (for me):

$ freebsd-version -kru
13.2-RELEASE-p8
13.2-RELEASE-p8
13.2-RELEASE-p9

$ pkg info -x xorg-server
xorg-server-21.1.10,1
$ pkg info -x xf86-video-nv
xf86-video-nv-2.1.22
Comment 37 Lena 2024-01-10 19:55:50 UTC
Latest versions from packages, currently
xf86-video-nv-2.1.22
xorg-server-21.1.10,1
worked for me under 12.4 and work now under 13.2 amd64,
CRT monitor HP P1120 attached to VGA socket of M2NPV-MX motherboard,
with /etc/X11/xorg.conf :

Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "Screen0" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
    Option         "AllowEmptyInput" "off"
EndSection

Section "Files"
    ModulePath      "/usr/local/lib/xorg/modules"
    FontPath	    "/usr/local/share/fonts/cyr-rfx-koi8-o/"
    FontPath        "/usr/local/share/fonts/webfonts/"
    FontPath        "/usr/local/share/fonts/cyrillic/"
    FontPath        "/usr/local/lib/X11/fonts/local/"
    FontPath        "/usr/local/share/fonts/misc/"
    FontPath        "/usr/local/share/fonts/dejavu/"
    FontPath        "/usr/local/share/fonts/TTF/"
    FontPath        "/usr/local/share/fonts/OTF"
    FontPath        "/usr/local/share/fonts/Type1/"
    FontPath        "/usr/local/share/fonts/75dpi/:unscaled"
    FontPath        "/usr/local/share/fonts/100dpi/:unscaled"
    FontPath        "/usr/local/lib/X11/fonts/CID/"
    FontPath        "/usr/X11R6/lib/X11/fonts/Speedo/"
    FontPath        "/usr/local/lib/X11/fonts/75dpi/"
    FontPath        "/usr/local/lib/X11/fonts/100dpi/"
    FontPath        "/usr/local/share/fonts/bitstream-vera/"
    FontPath        "/usr/local/share/ghostscript/fonts/"
    FontPath        "/usr/local/share/fonts/freefont-ttf"
    FontPath        "/usr/local/share/fonts/terminus-font/"
EndSection

Section "Module"
    Load           "extmod"
        Load  "record"
    Load           "dbe"
    Load           "glx"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "keyboard"
    Option         "XkbRules" "xorg"
    Option         "XkbModel" "pc101"
    Option         "XkbLayout" "us,ru"
    Option         "XkbVariant" ",legacy"
    Option        "XkbOptions" "grp:caps_toggle,grp_led:caps,shift:breaks_caps"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "ZAxisMapping" "4 5"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/sysmouse"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
EndSection

Section "Device"
    Identifier     "Card0"
    Driver         "nv"
    VendorName     "nVidia Corporation"
    BoardName      "C51PV [GeForce 6150]"
       Option "UseEdidDpi"      "false"
       Option     "SWcursor" "on"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Card0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Viewport    0 0
        Depth       1
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       4
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       8
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       15
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       16
        Modes      "800x600"
    EndSubSection
    SubSection     "Display"

        Viewport    0 0
        Depth       24
	Modes	"1024x768"
    EndSubSection
EndSection

Section "ServerFlags"
       Option "BlankTime"    "9999"
       Option "StandbyTime"  "9999"
       Option "SuspendTime"  "9999"
       Option "OffTime"      "9999"
       Option "UseEdidDpi"      "false"
       Option "AutoAddDevices" "off"
EndSection

pkg info -o xorg* xf*

xorg-7.7_3                     x11/xorg
xorg-apps-7.7_4                x11/xorg-apps
xorg-docs-1.7.2,1              x11/xorg-docs
xorg-drivers-7.7_7             x11-drivers/xorg-drivers
xorg-fonts-7.7_1               x11-fonts/xorg-fonts
xorg-fonts-100dpi-7.7          x11-fonts/xorg-fonts-100dpi
xorg-fonts-75dpi-7.7           x11-fonts/xorg-fonts-75dpi
xorg-fonts-cyrillic-7.7        x11-fonts/xorg-fonts-cyrillic
xorg-fonts-miscbitmaps-7.7     x11-fonts/xorg-fonts-miscbitmaps
xorg-fonts-truetype-7.7_1      x11-fonts/xorg-fonts-truetype
xorg-fonts-type1-7.7           x11-fonts/xorg-fonts-type1
xorg-libraries-7.7_5           x11/xorg-libraries
xorg-server-21.1.10,1          x11-servers/xorg-server
xorgproto-2023.2               x11/xorgproto
xf86-input-keyboard-1.9.0_5    x11-drivers/xf86-input-keyboard
xf86-input-libinput-1.3.0      x11-drivers/xf86-input-libinput
xf86-input-mouse-1.9.3_4       x11-drivers/xf86-input-mouse
xf86-video-ati-19.1.0_6,1      x11-drivers/xf86-video-ati
xf86-video-nv-2.1.22           x11-drivers/xf86-video-nv
xf86-video-scfb-0.0.7_1        x11-drivers/xf86-video-scfb
xf86-video-vesa-2.5.0_2        x11-drivers/xf86-video-vesa
xf86dga-1.0.3_1                x11/xf86dga

`xgamma -gamma 2` works with nv but doesn't work with vesa.
Comment 38 Lena 2024-01-10 20:13:30 UTC
P.S. Sorry, incomplete xorg.conf in previous comment.

Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "Screen0" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
    Option         "AllowEmptyInput" "off"
EndSection

Section "Files"
    ModulePath      "/usr/local/lib/xorg/modules"
    FontPath	    "/usr/local/share/fonts/cyr-rfx-koi8-o/"
    FontPath        "/usr/local/share/fonts/webfonts/"
    FontPath        "/usr/local/share/fonts/cyrillic/"
    FontPath        "/usr/local/lib/X11/fonts/local/"
    FontPath        "/usr/local/share/fonts/misc/"
    FontPath        "/usr/local/share/fonts/dejavu/"
    FontPath        "/usr/local/share/fonts/TTF/"
    FontPath        "/usr/local/share/fonts/OTF"
    FontPath        "/usr/local/share/fonts/Type1/"
    FontPath        "/usr/local/share/fonts/75dpi/:unscaled"
    FontPath        "/usr/local/share/fonts/100dpi/:unscaled"
    FontPath        "/usr/local/lib/X11/fonts/CID/"
    FontPath        "/usr/X11R6/lib/X11/fonts/Speedo/"
    FontPath        "/usr/local/lib/X11/fonts/75dpi/"
    FontPath        "/usr/local/lib/X11/fonts/100dpi/"
    FontPath        "/usr/local/share/fonts/bitstream-vera/"
    FontPath        "/usr/local/share/ghostscript/fonts/"
    FontPath        "/usr/local/share/fonts/freefont-ttf"
    FontPath        "/usr/local/share/fonts/terminus-font/"
EndSection

Section "Module"
    Load           "extmod"
        Load  "record"
    Load           "dbe"
    Load           "glx"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "keyboard"
    Option         "XkbRules" "xorg"
    Option         "XkbModel" "pc101"
    Option         "XkbLayout" "us,ru"
    Option         "XkbVariant" ",legacy"
    Option        "XkbOptions" "grp:caps_toggle,grp_led:caps,shift:breaks_caps"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Buttons" "5"
    Option         "ZAxisMapping" "4 5"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/sysmouse"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    HorizSync       30.0 - 121.0  # HP P1120
    VertRefresh     48.0 - 160.0  # HP P1120
    DisplaySize  280 210
EndSection

Section "Device"
    Identifier     "Card0"
    Driver         "nv"
    VendorName     "nVidia Corporation"
    BoardName      "C51PV [GeForce 6150]"
       Option "UseEdidDpi"      "false"
       Option     "SWcursor" "on"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Card0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Viewport    0 0
        Depth       1
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       4
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       8
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       15
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       16
        Modes      "800x600"
    EndSubSection
    SubSection     "Display"

        Viewport    0 0
        Depth       24
	Modes	"1024x768"
    EndSubSection
EndSection

Section "ServerFlags"
       Option "BlankTime"    "9999"
       Option "StandbyTime"  "9999"
       Option "SuspendTime"  "9999"
       Option "OffTime"      "9999"
       Option "DontZap"      "false" # Ctrl-Alt-Backspace to kill X
       Option "UseEdidDpi"      "false"
       Option "AutoAddDevices" "off"
EndSection
Comment 39 Sergiy 2024-01-21 20:54:20 UTC
(In reply to Lena from comment #38)
Thanks for the info.

Unfortunately, my situation is stable...
Regardless of branches:

 - latest pkg branch:
$ pkg info -x xorg-server
xorg-server-21.1.10_1,1
$ pkg info -x xf86-video-nv
xf86-video-nv-2.1.22

I get:
...(EE) Caught signal 11 (Segmentation fault). Server aborting

 - quarterly pkg branch:
$ pkg info -x xorg-server
xorg-server-21.1.11_1,1
$ pkg info -x xf86-video-nv
xf86-video-nv-2.1.22

I get:
...(EE) Caught signal 11 (Segmentation fault). Server aborting

In both cases, only vesa works:
$ pkg info -x xf86-video-vesa
xf86-video-vesa-2.5.0_2

-----

Perhaps the following information is not very relevant here, but it may be useful.
I tried installing on another clean hdd OpenBSD 7.4 with X and it works fine by default..
Information from Xorg.0.log: X.Org X Server 1.21.1.8 + NV driver
(Loading /usr/X11R6/lib/modules/drivers/nv_drv.so
Module nv: vendor="X.Org Foundation"
compiled for 1.21.1.8, module version = 2.1.22).
And I get 1280x800.
I didn't expect this from OpenBSD.
And I understand that OpenBSD uses Xenocara.

Sorry if this information is redundant here.
Comment 40 Yusuf Khan 2024-01-24 01:30:14 UTC
Created attachment 247909 [details]
Patch that would pressumably let the strcmp() pass, edited as previous patch was not correct.
Comment 41 Yusuf Khan 2024-01-24 01:32:24 UTC
(In reply to Sergiy from comment #39)


I would guess the segfault is occurring from the lack of a name for some of the modes? If that was the case then the patch I attached would probably fix the segfault...This issue is what I would guess would be some DFP/Dualhead(or lack of) issue. That concerns the FlatPanel and DualHead x config params.
Comment 42 Yusuf Khan 2024-01-24 03:11:07 UTC
Comment on attachment 247909 [details]
Patch that would pressumably let the strcmp() pass, edited as previous patch was not correct.

>From 9ac823cf803c842c4455714f8a7899dc6f59e7f6 Mon Sep 17 00:00:00 2001
>From: Yusuf Khan <yusisamerican@gmail.com>
>Date: Tue, 23 Jan 2024 16:41:45 -0800
>Subject: [PATCH xf86-video-nv] nv/init: set default names and crt before
> validation
>
>Presumably would fix https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267606,
>a segfault probably resulting from the lack of a name on the modes.
>
>Signed-off-by: Yusuf Khan <yusisamerican@gmail.com>
>---
> src/nv_driver.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
>diff --git a/src/nv_driver.c b/src/nv_driver.c
>index d2634da..4f50aa4 100644
>--- a/src/nv_driver.c
>+++ b/src/nv_driver.c
>@@ -1339,6 +1339,27 @@ NVModesAdd(DisplayModePtr Modes, DisplayModePtr Additions)
>     return Modes;
> }
> 
>+/* Sometimes we need info from here and we dont get it for whatever reason */
>+static void
>+NVSetModesInfo(DisplayModePtr Modes, int adjustFlags)
>+{
>+    DisplayModePtr Mode;
>+
>+    if (!Modes) {
>+        return;
>+    }
>+
>+    Mode = Modes;
>+
>+    while (Modes->next) {
>+	Mode = Mode->next;
>+	xf86SetModeDefaultName(Mode);
>+	xf86SetModeCrtc(Mode, adjustFlags);
>+    }
>+
>+    return;
>+}
>+
> /* Mandatory */
> static Bool
> NVPreInit(ScrnInfoPtr pScrn, int flags)
>@@ -1975,6 +1996,7 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
>         if (i > 0)
>             VBESetModeParameters(pScrn, pNv->pVbe);
>     } else {
>+	NVSetModesInfo(pScrn->monitor->Modes, pScrn->adjustFlags);
>         i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
>                               pScrn->display->modes, clockRanges,
>                               NULL, 256, max_width,
>-- 
>2.43.0
>
Comment 43 Sergiy 2024-01-27 18:22:40 UTC
(In reply to Yusuf Khan from comment #42)
Thank you!

I tried but maybe I did something wrong...
I did it like this:
I downloaded the port tree to the virtual machine:
# git clone https://git.FreeBSD.org/ports.git -b 2024Q1 /usr/ports 

I also downloaded
https://xorg.freedesktop.org/archive/individual/drive
r/xf86-video-nv-2.1.22.tar.xz
And unpacked the archive and made the appropriate changes to the file nv_driver.c (22 insertions) in the appropriate places.

I created xf86-video-nv-2.1.22.tar.xz archive and copied it to /usr/ports/distfiles/xorg/driver

In the /usr/ports/x11-drivers/xf86-video-nv directory, made changes to the distinfo file according to the received archive (changed): SHA256.., SIZE...

.. I tried to build the pkg by running:
/usr/ports/x11-drivers/xf86-video-nv # make package
and got xf86-video-nv-2.1.22.pkg

Then transferred it to the laptop.
On the laptop, I deleted the original package xf86-video-nv-2.1.22.pkg, cleared the cache.
Copied the modified file xf86-video-nv-2.1.22.pkg to /var/cache/pkg and installed it
root@T0SHA:/var/cache/pkg # pkg add xf86-video-nv-2.1.22.pkg
Accordingly received
/usr/local/lib/xorg/modules/drivers/nv_drv.so

Rebooted.... And...

..
[    52.689] (II) NV(0): Panel is LVDS
[    52.689] (--) NV(0): VideoRAM: 262144 kBytes
[    52.689] (==) NV(0): Using gamma correction (1.0, 1.0, 1.0)
[    52.689] (EE) Segmentation fault at address 0x4c
[    52.689] (EE) 
Fatal server error:
[    52.690] (EE) Caught signal 11 (Segmentation fault). Server aborting
[    52.690] (EE) 

Perhaps this is the result of my activity.
Maybe I'm doing something completely wrong. 
Sorry.
Comment 44 Yusuf Khan 2024-01-28 06:24:38 UTC
(In reply to Sergiy from comment #43)
Hmm...I believe I am too dumb to adequetely solve this problem unless I use gdb on this but... I believe `NVSetModesInfo(pScrn->monitor->Modes, pScrn->adjustFlags);` might need to be NVSetModesInfo(pScrn->modePool, pScrn->adjustFlags);. Also the call to xf86SetModeCrtc should probably be removed.

I am half asleep right now so I 

1. Cant tell why(or maybe if??!?!) xf86ValidateModes() isnt setting the mode names necessary for the modePool

2. Cant tell why we cant just pull a:

@@ -1975,14 +1975,8 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
         if (i > 0)
             VBESetModeParameters(pScrn, pNv->pVbe);
     } else {
-        i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
-                              pScrn->display->modes, clockRanges,
-                              NULL, 256, max_width,
-                              512, 128, max_height,
-                              pScrn->display->virtualX,
-                              pScrn->display->virtualY,
-                              pNv->ScratchBufferStart,
-                              LOOKUP_BEST_REFRESH);
+        xf86ValidateModesSize(pScrn, pScrn->monitor->Modes,
+                                  max_width, max_height, 0);
+        i = 1;
     }
 
     if (i < 1 && pNv->FBDev) {

(personal modePool confusion)

---

If I was in front of an affected system , I would take my old patch, remove the xf86SetModeCrtc bit to see if that fixes anything(probably wont), then revert the changed to HEAD. After reverting to HEAD I would enable the FlatPanel and DualHead flags separately to see if vesa stuff works(50/50 chance it does). After that I would test the xf86ValidateModesSize patch above but I have no idea if that will work at all. Maybe a bug should be added to the xserver bug tracker for this issue, this probably affects other drivers(particularly i810).
Comment 45 Sergiy 2024-01-29 20:56:57 UTC
Created attachment 248068 [details]
Xorg.0.log OpenBSD xorg-server 1.21.1.8 + NV module version 2.1.22
Comment 46 Sergiy 2024-01-29 21:01:36 UTC
Created attachment 248069 [details]
gdb result (driver xf86-video-nv-2.1.22 unchanged, default).
Comment 47 Sergiy 2024-01-29 21:06:57 UTC
Comment on attachment 248069 [details]
gdb result (driver xf86-video-nv-2.1.22 unchanged, default).

>Script started on Mon Jan 29 11:22:22 2024
>root@T0sha2_db:/home/Black_N # gdb -c /h[K[K/home/Black_N/Xorg.core /usr/local/libexec /Xorg

>[35;1mGNU gdb (GDB) 13.2 [GDB v13.2 for FreeBSD][m
>Copyright (C) 2023 Free Software Foundation, Inc.
>License GPLv3+: GNU GPL version 3 or later <[32mhttp://gnu.org/licenses/gpl.html[m>
>This is free software: you are free to change and redistribute it.
>There is NO WARRANTY, to the extent permitted by law.
>Type "show copying" and "show warranty" for details.
>This GDB was configured as "x86_64-portbld-freebsd13.2".
>Type "show configuration" for configuration details.
>For bug reporting instructions, please see:
>[32m<https://www.gnu.org/software/gdb/bugs/>[m.
>Find the GDB manual and other documentation resources online at:
>    <[32mhttp://www.gnu.org/software/gdb/documentation/[m>.
>
>For help, type "help".
>Type "apropos word" to search for commands related to "word"...
>Reading symbols from [32m/usr/local/libexec/Xorg[m...
>[New LWP 100142]
>[New LWP 100143]
>
>warning: Could not load shared library symbols for [vdso].
>Do you need "set solib-search-path" or "set sysroot"?
>Core was generated by `/usr/local/libexec/Xorg :0 -auth /root/.serverauth.1002'.
>Program terminated with signal SIGABRT, Aborted.
>Sent by thr_kill() from pid 1015 and user 0.
>#0  [33mthr_kill[m () at [32mthr_kill.S[m:4
>4	thr_kill.S: No such file or directory.
>[Current thread is 1 (LWP 100142)]
>[?2004h(gdb) bt
>[?2004l
#0  [33mthr_kill[m () at [32mthr_kill.S[m:4
>#1  [34m0x0000000828dcd6f4[m in [33m__raise[m ([36ms=s@entry[m=6)
>    at [32m/usr/src/lib/libc/gen/raise.c[m:52
>#2  [34m0x0000000828e7ebc9[m in [33mabort[m () at [32m/usr/src/lib/libc/stdlib/abort.c[m:67
>#3  [34m0x000000000045de4c[m in [33mOsAbort[m () at [32m../os/utils.c[m:1352
>#4  [34m0x00000000004684b6[m in [33mAbortServer[m () at [32m../os/log.c[m:879
>#5  [34m0x0000000000465fd7[m in [33mFatalError[m (
>    [36mf[m=0x23a3de "Caught signal %d (%s). Server aborting\n") at [32m../os/log.c[m:1017
>#6  [34m0x000000000045a763[m in [33mOsSigHandler[m ([36msigno[m=11, [36msip[m=0x820658710, 
>    [36munused[m=0x8206583a0) at [32m../os/osinit.c[m:156
>#7  [34m0x000000082766eb6e[m in [33mhandle_signal[m ([36mactp=actp@entry[m=0x820658320, 
>    [36msig=sig@entry[m=11, [36minfo=info@entry[m=0x820658710, [36mucp=ucp@entry[m=0x8206583a0)
>    at [32m/usr/src/lib/libthr/thread/thr_sig.c[m:301
>#8  [34m0x000000082766e11f[m in [33mthr_sighandler[m ([36msig[m=11, [36minfo[m=0x0, 
>    [36m_ucp[m=0x828e54daa <thr_self+10>) at [32m/usr/src/lib/libthr/thread/thr_sig.c[m:246
>#9  [2m<signal handler called>[m
>#10 [33mstrcmp[m () at [32m/usr/src/lib/libc/amd64/string/strcmp.S[m:46
>#11 [34m0x000000000049cc5d[m in [33mxf86LookupMode[m ([36mscrp[m=0x83014fe00, [36mmodep[m=0x8301b5b80, 
>    [36mclockRanges[m=0x8300b4810, [36mstrategy[m=LOOKUP_BEST_REFRESH)
>    at [32m../hw/xfree86/common/xf86Mode.c[m:511
>#12 [34m0x000000000049b1c3[m in [33mxf86ValidateModes[m ([36mscrp[m=0x83014fe00, 
>    [36mavailModes[m=0x83013d0c0, [36mmodeNames[m=0x830087710, [36mclockRanges[m=0x8300b4810, 
>    [36mlinePitches[m=0x0, [36mminPitch[m=256, [36mmaxPitch[m=4080, [36mpitchInc[m=512, [36mminHeight[m=128, 
>    [36mmaxHeight[m=4096, [36mvirtualX[m=0, [36mvirtualY[m=0, [36mapertureSize[m=267845632, 
>    [36mstrategy[m=LOOKUP_BEST_REFRESH) at [32m../hw/xfree86/common/xf86Mode.c[m:1719
>#13 [34m0x000000083713f25a[m in [33mNVPreInit[m ([36mpScrn[m=0x83014fe00, [36mflags[m=0)
>    at [32mnv_driver.c[m:1978
>#14 [34m0x000000000048467d[m in [33mInitOutput[m ([36mpScreenInfo[m=0x54b8b8 <screenInfo>, 
>    [36margc[m=4, [36margv[m=0x820658de0) at [32m../hw/xfree86/common/xf86Init.c[m:478
>#15 [34m0x00000000002f9a6a[m in [33mdix_main[m ([36margc[m=4, [36margv[m=0x820658de0, [36menvp[m=0x820658e08)
>    at [32m../dix/main.c[m:190
>#16 [34m0x000000000050dc2a[m in [33mmain[m ([36margc[m=4, [36margv[m=0x820658de0, [36menvp[m=0x820658e08)
>    at [32m../dix/stubmain.c[m:34
>[?2004h(gdb) bt full
>[?2004l
#0  [33mthr_kill[m () at [32mthr_kill.S[m:4
>No locals.
>#1  [34m0x0000000828dcd6f4[m in [33m__raise[m ([36ms=s@entry[m=6)
>    at [32m/usr/src/lib/libc/gen/raise.c[m:52
>        [36mid[m = 100142
>#2  [34m0x0000000828e7ebc9[m in [33mabort[m () at [32m/usr/src/lib/libc/stdlib/abort.c[m:67
>        [36mact[m = {[36m__sigaction_u[m = {[36m__sa_handler[m = [34m0x0[m, [36m__sa_sigaction[m = [34m0x0[m}, 
>          [36msa_flags[m = 4564560, [36msa_mask[m = {[36m__bits[m = {4294967263, 4294967295, 
>              4294967295, 4294967295}}}
>#3  [34m0x000000000045de4c[m in [33mOsAbort[m () at [32m../os/utils.c[m:1352
>No locals.
>#4  [34m0x00000000004684b6[m in [33mAbortServer[m () at [32m../os/log.c[m:879
>No locals.
>#5  [34m0x0000000000465fd7[m in [33mFatalError[m (
>    [36mf[m=0x23a3de "Caught signal %d (%s). Server aborting\n") at [32m../os/log.c[m:1017
>        [36mbeenhere[m = 1
>        [36margs[m = {{[36mgp_offset[m = 24, [36mfp_offset[m = 48, 
>            [36moverflow_arg_area[m = [34m0x820657f30[m, [36mreg_save_area[m = [34m0x820657e30[m}}
>        [36margs2[m = {{[36mgp_offset[m = 8, [36mfp_offset[m = 48, 
>            [36moverflow_arg_area[m = [34m0x820657f30[m, [36mreg_save_area[m = [34m0x820657e30[m}}
>#6  [34m0x000000000045a763[m in [33mOsSigHandler[m ([36msigno[m=11, [36msip[m=0x820658710, 
>    [36munused[m=0x8206583a0) at [32m../os/osinit.c[m:156
>No locals.
>#7  [34m0x000000082766eb6e[m in [33mhandle_signal[m ([36mactp=actp@entry[m=0x820658320, 
>    [36msig=sig@entry[m=11, [36minfo=info@entry[m=0x820658710, [36mucp=ucp@entry[m=0x8206583a0)
>    at [32m/usr/src/lib/libthr/thread/thr_sig.c[m:301
>        [36muc2[m = {[36muc_sigmask[m = {[36m__bits[m = {0, 4294967295, 0, 0}}, [36muc_mcontext[m = {
>            [36mmc_onstack[m = 0, [36mmc_rdi[m = 0, [36mmc_rsi[m = 35165516480, 
>            [36mmc_rdx[m = 34903260032, [36mmc_rcx[m = 206158430216, [36mmc_r8[m = 34903263392, 
>            [36mmc_r9[m = 34903263152, [36mmc_rax[m = 1024, [36mmc_rbx[m = 0, 
>            [36mmc_rbp[m = 35046592752, [36mmc_r10[m = 0, [36mmc_r11[m = 0, [36mmc_r12[m = 0, 
>            [36mmc_r13[m = 34903260112, [36mmc_r14[m = 4398046511104, [36mmc_r15[m = 196616, 
>            [36mmc_trapno[m = 543521744, [36mmc_fs[m = 8, [36mmc_gs[m = 0, [36mmc_addr[m = 1024, 
>            [36mmc_flags[m = 0, [36mmc_es[m = 0, [36mmc_ds[m = 0, [36mmc_err[m = 35046592752, 
>            [36mmc_rip[m = 0, [36mmc_cs[m = 0, [36mmc_rflags[m = 0, [36mmc_rsp[m = 35045740768, 
>            [36mmc_ss[m = 0, [36mmc_len[m = 0, [36mmc_fpformat[m = 0, [36mmc_ownedfp[m = 0, 
>            [36mmc_fpstate[m = {0, 0, 0, 0, 0, 0, -4294967296, 0, 0, 0, 35165516480, 
>              35194167560, 34903261472, 35020778426, 0, 0, 0, 0, 0, 
>              35165516480, 0, 34903261520, 35046527704, 35046600176, 
>              34903261824, 2311003, 34903261504, 35020752016, 35046521264, 13, 
>              34903261632, 35045744854, 0, 35045741408, 35046592752, 0, 
>              35165516480, 35194167560, 34903261680, 35020778426, 34903261632, 
>              35045741015, 66, 34903262016, 0, 35165516480, 543523344, 
>              34903261760, 1, 1, 66, 35046592752, 34903261712, 35020752016, 
>              35046521264, 66, 34903261872, 35045724063, 34903262016, 66, 
>              34903261728, 1, 0, 35045741408}, [36mmc_fsbase[m = 35046592752, 
>            [36mmc_gsbase[m = 1095216660480, [36mmc_xfpustate[m = 4644985458150304907, 
>            [36mmc_xfpustate_len[m = 0, [36mmc_spare[m = {1, 0, -4808989965519753994, 0}}, 
>          [36muc_link[m = [34m0x200[m, [36muc_stack[m = {[36mss_sp[m = [34m0xff0[m, [36mss_size[m = 4096, 
>[?2004h--Type <RET> for more, q to quit, c to continue without paging--c
>[?2004l
            [36mss_flags[m = 128}, [36muc_flags[m = 543523568, [36m__spare__[m = {8, 4615166, 0, 
>            66}}
>        [36mcurthread[m = [34m0x830073000[m
>        [36min_sigsuspend[m = 0
>        [36mcancel_enable[m = 1
>        [36mcancel_point[m = 0
>        [36msigfunc[m = [34m0x0[m
>        [36merr[m = [2m<optimized out>[m
>        [36mcancel_async[m = [2m<optimized out>[m
>#8  [34m0x000000082766e11f[m in [33mthr_sighandler[m ([36msig[m=11, [36minfo[m=0x0, 
>    [36m_ucp[m=0x828e54daa <thr_self+10>) at [32m/usr/src/lib/libthr/thread/thr_sig.c[m:246
>        [36mact[m = {[36m__sigaction_u[m = {[36m__sa_handler[m = [34m0x45a650[m <[33mOsSigHandler[m>, 
>            [36m__sa_sigaction[m = [34m0x45a650[m <[33mOsSigHandler[m>}, [36msa_flags[m = 64, 
>          [36msa_mask[m = {[36m__bits[m = {1024, 0, 0, 0}}}
>        [36merr[m = 20
>        [36mcurthread[m = [34m0x830073000[m
>        [36mucp[m = [2m<optimized out>[m
>        [36musa[m = [2m<optimized out>[m
>#9  [2m<signal handler called>[m
>No symbol table info available.
>#10 [33mstrcmp[m () at [32m/usr/src/lib/libc/amd64/string/strcmp.S[m:46
>No locals.
>#11 [34m0x000000000049cc5d[m in [33mxf86LookupMode[m ([36mscrp[m=0x83014fe00, [36mmodep[m=0x8301b5b80, 
>    [36mclockRanges[m=0x8300b4810, [36mstrategy[m=LOOKUP_BEST_REFRESH)
>    at [32m../hw/xfree86/common/xf86Mode.c[m:511
>        [36mtype[m = 64
>        [36mp[m = [34m0x8301b5ac0[m
>        [36mbestMode[m = [34m0x0[m
>        [36mcp[m = [34m0x0[m
>        [36mi[m = 0
>        [36mk[m = 0
>        [36mgap[m = 0
>        [36mminimumGap[m = 2001
>        [36mrefresh[m = 2.3889185624127413e-317
>        [36mbestRefresh[m = 0
>        [36mfound[m = 0
>        [36mextraFlags[m = 0
>        [36mclockIndex[m = -1
>        [36mMulFactor[m = 1
>        [36mDivFactor[m = 1
>        [36mModePrivFlags[m = 0
>        [36mstatus[m = [36mMODE_NOMODE[m
>        [36mallowDiv2[m = 0
>        [36mn[m = 5
>        [36mtypes[m = {9, 1, 40, 32, 72, 64, 0}
>        [36mntypes[m = 7
>#12 [34m0x000000000049b1c3[m in [33mxf86ValidateModes[m ([36mscrp[m=0x83014fe00, 
>    [36mavailModes[m=0x83013d0c0, [36mmodeNames[m=0x830087710, [36mclockRanges[m=0x8300b4810, 
>    [36mlinePitches[m=0x0, [36mminPitch[m=256, [36mmaxPitch[m=4080, [36mpitchInc[m=512, [36mminHeight[m=128, 
>    [36mmaxHeight[m=4096, [36mvirtualX[m=0, [36mvirtualY[m=0, [36mapertureSize[m=267845632, 
>    [36mstrategy[m=LOOKUP_BEST_REFRESH) at [32m../hw/xfree86/common/xf86Mode.c[m:1719
>        [36mrepeat[m = 0
>        [36mp[m = [34m0x8301b5b80[m
>        [36mq[m = [34m0x8301b5ac0[m
>        [36mr[m = [34m0x690[m
>        [36mnew[m = [34m0x8301b5b80[m
>        [36mlast[m = [34m0x8301b5b80[m
>        [36mendp[m = [34m0x8301b5b88[m
>        [36mi[m = 1
>        [36mnumModes[m = 0
>        [36mstatus[m = [36mMODE_OK[m
>        [36mlinePitch[m = -1
>        [36mvirtX[m = 0
>        [36mvirtY[m = 0
>        [36mnewLinePitch[m = 8
>        [36mnewVirtX[m = 773883912
>        [36mnewVirtY[m = 8
>        [36mmodeSize[m = 923997624
>        [36mvalidateAllDefaultModes[m = 1
>        [36muserModes[m = 1
>        [36msaveType[m = 32
>        [36mBankFormat[m = [34m0x83014fe50[m
>        [36mcp[m = [34m0x0[m
>        [36mnumTimings[m = 0
>        [36mhsync[m = {{[36mhi[m = 1.94434593e-19, [36mlo[m = 1.12103877e-44}, {[36mhi[m = 8671373, 
>            [36mlo[m = 2.07812562e-41}, {[36mhi[m = 0, [36mlo[m = 0}, {[36mhi[m = 0, [36mlo[m = 0}, {
>            [36mhi[m = 3.58732407e-43, [36mlo[m = 0}, {[36mhi[m = 0, [36mlo[m = 0}, {
>            [36mhi[m = 5.42030421e-10, [36mlo[m = 1.12103877e-44}, {[36mhi[m = 5.37749401e-10, 
>            [36mlo[m = 1.12103877e-44}}
>        [36mvrefresh[m = {{[36mhi[m = 6.76031221e-39, [36mlo[m = 0}, {[36mhi[m = 3.07585573e-39, 
>            [36mlo[m = 0}, {[36mhi[m = 4.64922804e-41, [36mlo[m = 0}, {[36mhi[m = 5.73971851e-42, 
>            [36mlo[m = 0}, {[36mhi[m = 1.94439867e-19, [36mlo[m = 1.12103877e-44}, {[36mhi[m = 0, 
>            [36mlo[m = 0}, {[36mhi[m = 5.71729773e-42, [36mlo[m = 0}, {[36mhi[m = 5.60519386e-45, 
>            [36mlo[m = 0}}
>        [36minferred_virtual[m = 0
>#13 [34m0x000000083713f25a[m in [33mNVPreInit[m ([36mpScrn[m=0x83014fe00, [36mflags[m=0)
>    at [32mnv_driver.c[m:1978
>        [36mpNv[m = [34m0x8300c3800[m
>        [36mfrom[m = [36mX_PROBED[m
>        [36mi[m = 773853856
>        [36mmax_width[m = 4080
>        [36mmax_height[m = 4096
>        [36mclockRanges[m = [34m0x8300b4810[m
>        [36ms[m = [34m0x0[m
>        [36mconfig_mon_rates[m = 1
>#14 [34m0x000000000048467d[m in [33mInitOutput[m ([36mpScreenInfo[m=0x54b8b8 <screenInfo>, 
>    [36margc[m=4, [36margv[m=0x820658de0) at [32m../hw/xfree86/common/xf86Init.c[m:478
>        [36mi[m = 0
>        [36mj[m = 0
>        [36mk[m = 0
>        [36mscr_index[m = 0
>        [36mmodulelist[m = [34m0x0[m
>        [36moptionlist[m = [34m0x830087ba0[m
>        [36mautoconfig[m = 0
>        [36msigio_blocked[m = 0
>        [36mwant_hw_access[m = 1
>        [36mconfigured_device[m = [34m0x830160300[m
>#15 [34m0x00000000002f9a6a[m in [33mdix_main[m ([36margc[m=4, [36margv[m=0x820658de0, [36menvp[m=0x820658e08)
>    at [32m../dix/main.c[m:190
>        [36mi[m = 256
>        [36malwaysCheckForInput[m = {0, 1}
>#16 [34m0x000000000050dc2a[m in [33mmain[m ([36margc[m=4, [36margv[m=0x820658de0, [36menvp[m=0x820658e08)
>    at [32m../dix/stubmain.c[m:34
>No locals.
>[?2004h(gdb) exit
>[?2004l
root@T0sha2_db:/home/Black_N # ^Dexit
>
>Script done on Mon Jan 29 11:28:31 2024
Comment 48 Sergiy 2024-01-29 21:16:15 UTC
(In reply to Yusuf Khan from comment #44)
OK !!
It will probably be difficult with me... I'm sorry.

I installed FreeBSD 13.2 on another drive (goodbye OpenBSD), updated it, installed a port tree, compiled xorg-server, xorg, xf86-video-nv with debug flags:

root@T0sha2_db:/usr/local/libexec # file Xorg 
Xorg: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked 
, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.2, FreeBSD-style, with debug_ 
info, not stripped  

root@T0sha2_db:/usr/local/lib/xorg/modules/drivers # file vesa_drv.so 
vesa_drv.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, for FreeBSD 13.2, with debug_info, not stripped 

root@T0sha2_db:/usr/local/lib/xorg/modules/drivers # file nv_drv.so 
nv_drv.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, for FreeBSD 13.2, with debug_info, not stripped

When using vesa and startx I get a working TWM.

Using the default NV has the same effects as the main drive.
For information, I attach:
 - Xorg.0.log OpenBSD xorg-server 1.21.1.8, NV module version 2.1.22;
 - gdb result (driver xf86-video-nv-2.1.22 unchanged, default).

----

The next step.
I wanted to apply the changes (post 42) to try to get the output from gdb.
But the previous time when I modified the nv_driver.c file directly (adding 22 insertions) I did not pay attention to the contents of the ports tree directory (this is my fail):
... xf86-video-nv/files/patch-src-nv_driver.c
with a patch file for exactly the same file and which I made changes to.
Sorry for my ignorance and wasting your time, but the build will obviously use this patch as well.

The first part concerns him
@@ -911,6 +911,8 ...
and apparently the changes (post 42) do not affect it.
But after I changed the file nv_driver.c (post 42)
-1339.6 +1339.27 ...
increasing the number of lines by 21 and the second part of the port tree patch, which is about changes
@@ -1543,7 +1546,11 ...
will not be used where it is needed.
Maybe I need to change this file
patch-src-nv_driver.c
Namely
@@ -1543,7 +1546,11 ...
on
@@ -1564,7 +1567,11 ...
I hope it works.
Comment 49 Yusuf Khan 2024-01-30 08:06:27 UTC
(In reply to Sergiy from comment #48)
I think I will have to work on it myself on hardware as I dont have enough X knowledge to do this without a high amount of trial and error. Your OpenBSD logs are showing that your pruning more than just bad panel dimensions(which I probably should have expected), so the small hack job diff I sent you last time wont work.

As you seem to have emptied your OpenBSD drive, I have a diff that is simply just what the intel driver uses to do it but its *simply copied code from the intel driver* and is by *no means recommended to use on your computer* due to my inexperience with X. I will hopefully get hardware to test this later on and fix it up.

The bellow is a diff that should, if the above warnings are read, be run without any other modifications to mode validation.

From 6f0ec68b9fc4c0f062e483a96665fbcb378408ea Mon Sep 17 00:00:00 2001
From: Yusuf Khan <yusisamerican@gmail.com>
Date: Mon, 29 Jan 2024 23:52:34 -0800
Subject: [PATCH xf86-video-nv] Intel import fix

---
 src/nv_driver.c | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/nv_driver.c b/src/nv_driver.c
index 134da6a..6c40ebe 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1976,14 +1976,39 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
         if (i > 0)
             VBESetModeParameters(pScrn, pNv->pVbe);
     } else {
-        i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
-                              pScrn->display->modes, clockRanges,
-                              NULL, 256, max_width,
-                              512, 128, max_height,
-                              pScrn->display->virtualX,
-                              pScrn->display->virtualY,
-                              pNv->ScratchBufferStart,
-                              LOOKUP_BEST_REFRESH);
+        DisplayModePtr i, m, p = NULL;
+       int max_x = 0, max_y = 0;
+        float max_vrefresh = 0.0;
+
+       for (m = pScrn->monitor->Modes; m; m = m->next) {
+               if (m->type & M_T_PREFERRED)
+                        p = m;
+               max_x = max(max_x, m->HDisplay);
+               max_y = max(max_y, m->VDisplay);
+               max_vrefresh = max(max_vrefresh, xf86ModeVRefresh(m));
+         }
+
+         max_vrefresh = max(max_vrefresh, 60.0);
+         max_vrefresh *= (1 + SYNC_TOLERANCE);
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,0,0)
+        pScrn->modePool = xf86GetDefaultModes();
+#else
+        pScrn->modePool = xf86GetDefaultModes(0,0);
+#endif
+       xf86ValidateModesSize(pScrn, pScrn->modePool, max_width, max_height, 0);
+
+        for (i = m; i; i = i->next) {
+               if (xf86ModeVRefresh(i) > max_vrefresh)
+                       i->status = MODE_VSYNC;
+               if (p && i->HDisplay >= p->HDisplay &&
+                    i->VDisplay >= p->VDisplay &&
+                    xf86ModeVRefresh(i) >= xf86ModeVRefresh(p))
+                        i->status = MODE_VSYNC;
+        }
+
+        xf86PruneInvalidModes(pScrn, &m, FALSE);
+
+        pScrn->monitor->Modes = xf86ModesAdd(pScrn->monitor->Modes, m);
     }

     if (i < 1 && pNv->FBDev) {
--
2.43.0




TLDR; Patch wont work on FreeBSD based on your OpenBSD output, potential diff(probably something wrong with it due to my X experience) that you probably shouldnt apply unless your actually desperate, and I will hopefully try to reproduce the issue myself.
Comment 50 Sergiy 2024-02-04 15:41:41 UTC
Thank you all!
I am not giving up on further attempts to understand what happened to my Toshiba Satellite A200-1GS after the update (2022.10.10):
...
xorg-server: 1.20.14,1 -> 21.1.4_1,1
...
xf86-video-nv: 2.1.21_4 -> 2.1.21_5
but it was at this stage that something happened.

The source code of xf86-video-nv has hardly changed significantly since then. The open source nv Xenocara module also almost matches xf86-video-nv-2.1.22, but it works on OpenBSD with this laptop. 
As well as xf86Mode.c in xorg-servers and Xenocara did not change.

There were no hardware changes, it's the same Toshiba Satellite A200-1GS...
I see (from my notes) that my attempts to find something, I don't know what, are going in more than one circle. Yes, I lack knowledge.... Sorry.

Given the fact that the xf86-video-nv driver still works fine for many and is the driver of last resort for some PCs, I'm aware of the implications of changing it.
---

Surprisingly, I tried to change the hardware of my Toshiba Satellite A200-1GS to some extent - I connected a Dell SP2208WFP monitor through the laptop's VGA connector.
And startx without any configuration files in xorg.conf.d and I got native for this monitor - 1680x1050 in TWM:

xrandr: Failed to get size of gamma for output default 
Screen 0: minimum 320 x 240, current 1680 x 1050, maximum 1680 x 1050 
default connected 1680x1050+0+0 0mm x 0mm 
   1680x1050     60.00* 
   1400x1050     75.00    60.00   
   1600x900      60.00   
   1280x1024     75.00    60.00   
   1400x900      60.00   
   1280x960      60.00   
   1368x768      60.00   
   1280x800      60.00   
   1152x864      75.00   
   1280x720      60.00   
   1024x768      75.00    70.00    60.00   
   896x672       60.00   
   1024x576      60.00   
   960x600       60.00   
   832x624       75.00   
   960x540       60.00   
   800x600       75.00    72.00    65.00    60.00    56.00   
   840x525       60.00   
   864x486       60.00   
   700x525       75.00    60.00   
   800x450       60.00   
   640x512       75.00    60.00   
   700x450       60.00   
   640x480       75.00    73.00    60.00   
   720x400       70.00   
   684x384       60.00   
   640x400       60.00   
   576x432       75.00   
   640x360       60.00   
   512x384       75.00    70.00    60.00   
   512x288       60.00   
   416x312       75.00   
   480x270       60.00   
   400x300       75.00    72.00    60.00    56.00   
   432x243       60.00   
   320x240       75.00    73.00    60.00 

So the driver xf86-video-nv-2.1.22 works without problems on this laptop but with a different monitor. 

Why with native monitor I get:
...
[    34.107] (II) NV(0): Not using default mode "1280x800" (bad mode clock/interlace/doublescan) 
[    34.107] xf86InitialCheckModeForDriver(0x83413aa00, 0x834186280 (null), 0x8340a07e0, 0x1, 4080, 0, 0) 
[    34.107] xf86CheckModeForMonitor(0x834186280 (null), 0x83412c1c0 <default monitor>) 
[    34.107] (EE) Segmentation fault at address 0x0 
[    34.107] (EE) 
Fatal server error: 
[    34.107] (EE) Caught signal 11 (Segmentation fault). Server aborting
...

Whereas on OpenBSD the same monitor:
...
[    22.555] (II) NV(0): Not using default mode "1280x800" (bad mode clock/interlace/doublescan) 
[    22.555] (II) NV(0): Virtual size is 1280x800 (pitch 1280)
...

And the same driver with a Dell monitor:
...
[    37.869] (II) NV(0): Virtual size is 1680x1050 (pitch 1680)
...

I can not understand...
Comment 51 Yusuf Khan 2024-02-04 21:29:54 UTC
(In reply to Sergiy from comment #50)
Its because its probably triggering the VBE codepath. Or because Xorg cant get the monitors name, or new Xorg versions dont assign names to all of the monitors.
Comment 52 Sergiy 2024-02-19 21:52:14 UTC
(In reply to Yusuf Khan from comment #51)
Ok, I have some result.
I followed the path of inspecting the source code of the hw directory changes:
xorg-server-1.20.14 (which worked)
xorg-server-21.1.4 (stopped working)
xorg-server-21.1.11 (installed now)
Xenocara (OpenBSD worked).
I will not describe in detail, the process itself...

And the differences made by the OpenBSD developers in the file hw/xfree86/modes/xf86Modes.c helped me:

--- 2024_xorg-server-21.1.11/xorg-server-21.1.11/hw/xfree86/modes/xf86Modes.c	2024-01-16 11:59:07.000000000 +0200
+++ 2024_Xenocara_xserver/hw/xfree86/modes/xf86Modes.c	2024-01-31 15:22:06.000000000 +0200
@@ -803,10 +803,14 @@
 {
     struct libxcvt_mode_info *libxcvt_mode_info;
     DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+    char *tmp;
 
     libxcvt_mode_info =
         libxcvt_gen_mode_info(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);
 
+    XNFasprintf(&tmp, "%dx%d", HDisplay, VDisplay);
+    Mode->name = tmp;
+    
     Mode->VDisplay   = libxcvt_mode_info->vdisplay;
     Mode->HDisplay   = libxcvt_mode_info->hdisplay;
     Mode->Clock      = libxcvt_mode_info->dot_clock;

I modified this file in the xorg-server-21.1.11 source code (or rather borrowed it from Xenocara), created the xorg-server-21.1.11.tar.xz archive and downloaded it to /usr/ports/distfiles/ on my laptop.

In the xorg-server directory of the port tree, made changes to the distinfo file according to the received archive (changed): SHA256.., SIZE...
and: 
# make install 
...
# make clean

(Having first removed the installed xorg-server.)

As a result, when I enter startx, I get TWM on the laptop screen with a native extension of 1280x800.

This worked for me.

I will try to create a suitable package to replace xorg-server on a different, non-test disk.
Comment 53 Yusuf Khan 2024-02-19 22:33:09 UTC
(In reply to Sergiy from comment #52)
Your laptop monitor used Vesa Flatpanel?! I was assuming the other monitor you were using was the one using it :skull: 

If you want, I can send the upstream MR to backport this to xserver 21 if you wish and state how you want to be credited, or you can send an MR yourself.
Comment 54 Sergiy 2024-02-19 23:09:50 UTC
(In reply to Yusuf Khan from comment #53)
I will be grateful if you do it.

I hope these changes will not harm anyone.
Comment 55 Yusuf Khan 2024-02-20 00:19:27 UTC
(In reply to Sergiy from comment #54)
Is `Reported-by: Sergiy <Black_N AT ukr DOT net>` fine?
Comment 56 Sergiy 2024-02-20 09:24:23 UTC
(In reply to Yusuf Khan from comment #55)
OK! Thank you very much!
Comment 57 Sergiy 2024-04-06 20:55:42 UTC
Today I did a pkg update:
...
xorg-server: 21.1.11_1,1 -> 21.1.12,1
...
The update replaced the change package I created, but this works fine for me: 
xorg-server-21.1.12,1 + xf86-video-nv-2.1.22

$ freebsd-version -kru
13.2-RELEASE-p11
13.2-RELEASE-p11
13.2-RELEASE-p11

I can't answer for the thread author, but my problem is solved.

Thank you very much for your help!