c++ program reboots system.

c++ program reboots system.

Post by Richard B. Johnso » Tue, 14 May 2002 21:10:09



I didn't save the address of the person who reported the reboot
error...
This c++ code was reported to reboot a machine.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iterator>
using namespace std;
int main(int argc, char** argv)
{
    string raw_filename = "input.out";
    ifstream raw_file(raw_filename.c_str());
    vector<long> data;
    copy(istream_iterator<long>(raw_file),istream_iterator<long>(),back_inserter(data));
    data.erase(data.begin());
    return 0;

Quote:}

Script started on Mon May 13 07:51:12 2002
# gdb xxx
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.15 (i586-unknown-linux), Copyright 1995 Free Software Foundation, Inc...
(gdb) run
Starting program: /root/xxx

Program received signal SIGSEGV, Segmentation fault.
ostream::flush (this=0x8c224) at iostream.cc:864
864         if (_strbuf->sync())
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
# exit
exit
Script done on Mon May 13 07:51:49 2002

On Linux 2.4.18, the program just seg-faults (as it should).
On the version you are using, you should write a 'C' program
that does lseek() beyond EOF. There could be a bug there, but
otherwise I can't tell from the program presented.

Cheers,
* Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

                 Windows-2000/Professional isn't.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://www.veryComputer.com/
Please read the FAQ at  http://www.veryComputer.com/

 
 
 

c++ program reboots system.

Post by rpm » Wed, 15 May 2002 01:10:08


Quote:> }
> Script started on Mon May 13 07:51:12 2002
> # gdb xxx
> GDB is free software and you are welcome to distribute copies of it
>  under certain conditions; type "show copying" to see the conditions.
> There is absolutely no warranty for GDB; type "show warranty" for details.
> GDB 4.15 (i586-unknown-linux), Copyright 1995 Free Software Foundation,
> Inc... (gdb) run
> Starting program: /root/xxx

> Program received signal SIGSEGV, Segmentation fault.
> ostream::flush (this=0x8c224) at iostream.cc:864
> 864            if (_strbuf->sync())
> (gdb) quit
> The program is running.  Quit anyway (and kill it)? (y or n) y
> # exit
> exit
> Script done on Mon May 13 07:51:49 2002

> On Linux 2.4.18, the program just seg-faults (as it should).
> On the version you are using, you should write a 'C' program
> that does lseek() beyond EOF. There could be a bug there, but
> otherwise I can't tell from the program presented.

I executed the same C++ code on iPAQ , on the 2.4.7 kernel and it works fine !
no seg faults no reboots,
I also tried the C program you suggested , but that too works fine,  no
reboots no seg faults!   :(

rpm

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

c++ program reboots system.

Post by Richard B. Johnso » Wed, 15 May 2002 01:50:10



> > }
> > Script started on Mon May 13 07:51:12 2002
> > # gdb xxx
> > GDB is free software and you are welcome to distribute copies of it
> >  under certain conditions; type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB; type "show warranty" for details.
> > GDB 4.15 (i586-unknown-linux), Copyright 1995 Free Software Foundation,
> > Inc... (gdb) run
> > Starting program: /root/xxx

> > Program received signal SIGSEGV, Segmentation fault.
> > ostream::flush (this=0x8c224) at iostream.cc:864
> > 864       if (_strbuf->sync())
> > (gdb) quit
> > The program is running.  Quit anyway (and kill it)? (y or n) y
> > # exit
> > exit
> > Script done on Mon May 13 07:51:49 2002

> > On Linux 2.4.18, the program just seg-faults (as it should).
> > On the version you are using, you should write a 'C' program
> > that does lseek() beyond EOF. There could be a bug there, but
> > otherwise I can't tell from the program presented.

> I executed the same C++ code on iPAQ , on the 2.4.7 kernel and it works fine !
> no seg faults no reboots,
> I also tried the C program you suggested , but that too works fine,  no
> reboots no seg faults!   :(

This is the file I used...
`cp /dev/zero input.out` ^C after a second.

-rw-------   1 root     root     117010432 May 13 07:47 input.out

It seg-faults every time..

Cheers,
* Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

                 Windows-2000/Professional isn't.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://www.veryComputer.com/
Please read the FAQ at  http://www.veryComputer.com/

 
 
 

1. UNIX system rebooting when executing a program...

Is it EVER possible when a non-setuid process is started a UNIX system
can reboot. All my knowlege of UNIX seems to indicate that its not.

This program is started by a non-root user:

Let say I screwed in my program and have trashed my data,stack segment
and parameter passed to "syscall" indicates system call as "reboot".

Now isn't UNIX kernel going to verify that the process effective ID is not
root and syscall "reboot" is going to return and set errno to EPERM.
And since the effective user id of process information is stored in
kernel's data space my program has no way of screwing this up. So I say
its not possible for a process that is invoked by a non-root  user to
reboot the system under ANY damn circumstances.

What do you think??

PLEASE let me know.


------------------------------------------------------------------------------
#include <standard.disclaimer>

2. problems with sendmail

3. system reboot (was: crontab script reboot)

4. X

5. Unix Systems Network Programming with C++ Question

6. segment fault & paging directory: not good ...

7. Autoconf & configuring C++ programs for multiple Unix systems

8. motherboards & scsi

9. Best way to get system date time on Solaris from C++ program?

10. C++ Daemons, system programs?

11. where can I find source code for Unix System Programming Using C++ by Terrance Chan

12. Can you program advanced graphic programs(Java or C++)(NIEW)

13. How to run other programs within a C/C++ program?