|
|
Home » Developing U++ » U++ Developers corner » Raster::Line segfaults ... sometimes. (Adding a static counter somehow fixes the issue (for me).)
Raster::Line segfaults ... sometimes. [message #44068] |
Mon, 22 December 2014 08:04 |
rainbowsally
Messages: 29 Registered: December 2014
|
Promising Member |
|
|
Adding a static counter somehow fixed the issue (for me). And then considering that something might be choking on the cpu usage in this thread, I tried a 'usleep()' which also works, and seems to be more consistent.
I am multithreading in linux. You might not have this problem.
In uppsrc/Draw/Raster.cpp I was getting seg faults ("illegal memory access") so I put a counter in the function noted below. And just adding a static counter fixed the problem.
Huh????
[Update: Well, it fixed it a little more than half the time.]
If you are having trouble with RasterTest try this. I can't see how it could do anything but add a delay (unless there's a bug in BLITZ), but I don't want to experiment any more with this at this time.
File: uppsrc/Draw/RasterLine.cpp
void Raster::Line::MakeRGBA() const
{
// -rs added these two lines
// static int cnt;
// cnt++;
// -rs replaced the above with this ONE line.. another "experiment".
usleep(500); // half a millisecond
ASSERT(fmtdata && raster);
int cx = raster->GetWidth();
// ...
Tested, 5 times, no crashes. I'm done for now.
The half millisecond delay gives the OS plenty of time to pass a time slice to other threads. Dunno what's causing this or where the best place to deal with this is, but it might be that a "io pause" something like this should be in the main event loop. At least in Linux.
May look into this later.
[Updated on: Mon, 22 December 2014 08:29] Report message to a moderator
|
|
|
Re: Raster::Line segfaults ... sometimes. [message #44076 is a reply to message #44068] |
Mon, 22 December 2014 20:34 |
Didier
Messages: 680 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Rainbowsally,
Quote:And just adding a static counter fixed the problem.
Huh???? .
When you encounter such behaviour : modification of an unrelated code that causes a correction (or a crash), this is mostly due to uninitialized variables ( somewhere in the code .... ).
I recommend launching valgrind on this : info should be very instructive.
[Updated on: Mon, 22 December 2014 20:35] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 26 00:16:59 CEST 2024
Total time taken to generate the page: 0.05471 seconds
|
|
|