Subject: Buggy C++ program causes solid hang in -current
To: None <port-alpha@NetBSD.org>
From: Lars Nordlund <lars.nordlund@hem.utfors.se>
List: port-alpha
Date: 06/07/2005 23:15:39
Hello
Compiling the attached source into a binary, and running it
# ./crash 1 2 3
1
<hang>
will hang my 3.99.5 NetBSD/Alpha solidly 3 times out of 3 tries. No
response at all afterwards. Machine stays in X with perfect display,
except the frozen state. I have yet to try the program without X
running.
I am not really sure if I have managed to turn on "crash hard on
alignment error", should there be any switch like that?
Top of dmesg:
Digital AlphaPC 164LX 599 MHz, s/n
8192 byte page size, 1 processor.
total memory = 512 MB
(2120 KB reserved for PROM, 509 MB used by NetBSD)
C++ source:
(the bug is in the second for loop; argc is not a valid size of the
vector since only argc-1 elements are in it)
#include <iostream>
#include <vector>
using std::vector;
using std::string;
using std::cout;
using std::cerr;
using std::endl;
int
main(int argc, char** argv)
{
vector<string>elements;
// skip command name, start at 1
for (int i = 1; i < argc; ++i) {
elements.push_back(argv[i]);
}
for (vector<string>::size_type i = 0; i < argc; ++i) {
cout << elements[i] << endl;
}
return 0;
}
You have been warned, save all your buffers before runnin.. ;-)
Best regards
Lars Nordlund