# A linux app causes reboot of FBSD13.  Where do I start the search?



## debguy (May 16, 2021)

A "major" linux app (for ubuntu-18-20) (uses Qt, QtOpenGL and Java, is multi-threaded) actually *causes FreeBSD to reboot*. No messages in /var/log why. The app runs as a normal user. The last version runs very well: but the GUI has compiled against "new versions of everything bad" (not that anyone could tell there was a reason - the app doesn't use any of the all new libs?)

I'm un-aware if "normal users" have authority to execute HALT on Intel platforms running freebsd which is basically my question (i hope not):  So where in the kernel might execute halt in a panic rather than shutdown due to ... linux emulation missing support?  *Or should I heavily suspect a video driver fault not the kernel*? That's really my only question. What in freeBSD would panic to HALT or if nVidia card can cause reboot? Or does Xorg have any "halt" instructions hidden somewhere if it flubs?

All I know is the screen goes dark very soon after the app begins to load and reboot happens 1 sec after (normal load is: a 5 sec disk read, then a 2D spash comes up showing progress loading another 5-10 sec).  So I'm unsure I can blame GL but maybe.  It's just plain strange to me I've never had an app running as a normal user reboot a unix like that before.


----------



## zirias@ (May 16, 2021)

debguy said:


> A "major" linux app (for ubuntu-18-20) (uses Qt, QtOpenGL and Java, is multi-threaded) actually *causes FreeBSD to reboot*.


I call bullshit.

(yes, not even naming it for others to reproduce is part of the "game". boring.)


----------



## debguy (May 16, 2021)

it is mathematica 12.2, the kernel works but not the front end.  11.3 (with java replaced with 12.2's) works, 11.0 works.  So something in 12.2's front-end.

I have a knot of "ldd" reports MANY libs the front end "pre-requires" (remembe netscape navigator loaded it's own objects and could run if they weren't shipped but with less rendering?  that was _design_). Then i also have that the binary was compiled for ubuntu/linux not freebsd: and their asm hacks are only getting more complicated so i can't rule that out.

anyhow.  i was trying to avoid TMI.

*the basic question is*, for "freebsd 13 just reboots when a user app is run", could an app do that? or should I know only the kernel can? or linux causes that sometimes? or no, i should be expecting it was video related, or no, video<>linux related?

there are a ton of libs i could each test as linux enabled or mapped to freebsd's available.  i see sometimes both are present (perhaps because i installed too many c7 pkgs) and ldd shows one is chosen freebsd or linux.  take a good long while to chase them all down.

I was hoping if anyone knew "what are the basic things that cause a reboot" (which are likely rare) where that is in kernel if those have anything to do with an app loading ... that this would cut my search time down a bit.


----------



## debguy (May 16, 2021)

anyway!  just fishing for info on what people know about FreeBSD kernel RESET/HALT where in kernel they are, or if they know it must be in c7, or some "convenient information" about reboots


----------



## kpedersen (May 16, 2021)

debguy said:


> It's just plain strange to me I've never had an app running as a normal user reboot a unix like that before.


Really? You should have been around in the IRIX / Solaris days. Buggy graphics drivers have always been around. Even "modern" unix-like platforms like FreeBSD, OpenBSD and Linux have them.

Also, you show a potential lack of understanding of the graphics stack. Yes you are running a program as a user. However that then connects further down to Xorg and then further to the NVIDIA/AMD subsystems that are very much not running as a standard user. They can effectively do what they like.


----------



## bakul (May 16, 2021)

You have likely tickled some bug in either the kernel proper or, more likely, the graphics driver. One suggestion is to ssh in to the machine from another and start your program from the shell with something like `DISPLAY=localhost:0.0 truss mathematica` or whatever. At least you will know what syscalls were made before it died.

Another suggestion is to use a serial console so that you can see where exactly the kernel crashed. You are not seeing how the kernel crashed because X has taken over your main screen. The FreeBSD handbook should have the details on how to set up a serial console, do a backtrace from ddb etc.

Alternatively enable crashdump and do a postmortem analysis. Start with "man crash" and read related man pages. Note: I haven't tried this in last 15 years or so & I have no idea what has changed since then. Note that even if you know where exactly the kernel crashed, most likely you won't be able to do anything about it.

So here is my recommendation: if you are just _playing_ mathematica, don't waste your time with any of this! If you absolutely _need_ it for your work, switch to a supported platform. If you want to play with _symbolic algebra_, there is always maxima! If you want to do all this to  learn _more about freebsd_, there are better ways of achieving that goal!


----------



## mark_j (May 16, 2021)

debguy said:


> anyway!  just fishing for info on what people know about FreeBSD kernel RESET/HALT where in kernel they are, or if they know it must be in c7, or some "convenient information" about reboots


What's c7? If freebsd crashes it's general protection faults and they're the domain of the processor to trampoline out of the issue. If freebsd halts then that's a controlled procedure.

If something is crashing your kernel, then read up on kernel crash dumps. https://docs.freebsd.org/en/books/developers-handbook/kerneldebug/


----------



## tingo (May 17, 2021)

Is the app packaged as an AppImage?


----------



## richardtoohey2 (May 17, 2021)

debguy said:


> *the basic question is*, for "freebsd 13 just reboots when a user app is run", could an app do that? or should I know only the kernel can? or linux causes that sometimes?


Yes, it can happen on any OS.  No, it shouldn't happen on any OS.  Doesn't get you much further forward does it?  

Can't help with the specific issue, sorry.  Sometimes hardware/software fails, everything has bugs (including FreeBSD).

Good luck!


----------



## ralphbsz (May 17, 2021)

debguy said:


> ... causes FreeBSD to reboot. No messages in /var/log why. The app runs as a normal user.


OK, you found a bug. Now describe it in such a fashion that a developer can reproduce it. Ideally, using only released software.



> I'm un-aware if "normal users" have authority to execute HALT ...


No, the halt instruction has nothing to do with it. Only the kernel can do these things. User applications simply are not allowed to cause a reboot or a halt. This is a bug, so it's not useful to ask about authority.



> So where in the kernel ...


I'm obviously not sure, but my hunch would be the graphics and video subsystem. It is probably being exercised in a fashion that didn't happen during normal testing.  I like the idea of using truss ... but most likely, this is not a system call per se, but rendering. I also like the idea of getting access to the console, although again, you might not see much useful stuff there. It's quite possible that what is reported on the console is already a victim.



> ... Or does Xorg have any "halt" instructions hidden somewhere if it flubs?


I'm sure it doesn't just halt the CPU. But you are hung up on the halt instruction: it is probably not intentional. More likely, memory has been scrambled, or the PC has been moved so things are getting executed that aren't intended to be executed.



> It's just plain strange to me I've never had an app running as a normal user reboot a unix like that before.


It's certainly rare for a shipping production system. In development, it happens all the time. I used to do kernel file system development, and with buggy software in the kernel (such as: software written by me!), this happens all the time. One of my colleagues got the boot time down to 27 seconds (that was before SSDs existed); another had a second computer with serial port hooked to the kernel debugger all the time. My goal in life was to get the source package for our file system to unpack and build, with the on the the file system we were building.



debguy said:


> *the basic question is*, for "freebsd 13 just reboots when a user app is run", could an app do that? or should I know only the kernel can? or linux causes that sometimes? or no, i should be expecting it was video related, or no, video<>linux related?


No, this is a bug. Just need to find it.



bakul said:


> So here is my recommendation: if you are just _playing_ mathematica, don't waste your time with any of this! If you absolutely _need_ it for your work, switch to a supported platform. If you want to play with _symbolic algebra_, there is always maxima! If you want to do all this to  learn _more about freebsd_, there are better ways of achieving that goal!


THIS. Raspberry Pi's come with a free mathematica license, so for about $30, you can get it to run legally.


----------

