Ask something - We can help.

Started by Stupot, Fri 19/12/2008 20:06:21

Previous topic - Next topic

Stupot

I have a question I want to ask but I didn't feel it was important enough to warrant it's own thread clogging up gen-gen.  So I thought I'd create this thread for all those niggling questions which pop up from time to time.

You know when you can remember parts of a film or a song but can't for the life of you remember the title?  Things like that.

So if you think about it in the future and have a niggling question which you don't feel deserves it's own thread (often the query is solved within the first few posts, anyway), then remember this thread lingering around waiting for your posers.  You guys are normally pretty good at these kinds of question.

-------------------------------------------------

So anyway.  Here's my question.

Back when the net was young, you would type in some random website names such as "www.ilovepizza.com" or "www.rhubarbandcustard.co.uk" and it would take you so a website who provided free email addresses based on hundreds and hundreds of such domain names...  I'm assuming they bought the domain names first and then dished out the corresponding email addresses for users... for example I could request "stupot@ilovepizza.com"

I can't remember what the actual website was called, I used to just type in random URLs and i'd eventualy find it...  But this was 10 or so years ago and I havent seen this website for ages...

Can anyone else remember the site that I am thinking of and does it still exist?
If not, what happened to the hundreds of URLs they owened?

cheers

RickJ


Paper Carnival

Ok, a question that has bothered me for a while.

In C, when you set a pointer to point to an unknown memory slot (either by adding to it or simply setting a number to it), is there any possibility to cause a segmentation fault or any problem at all?

Note I'm talking about pointing somewhere, but not reading/writing over there.

I personally think there should never be a problem, as long as you don't attempt to read/write over it, which may or may not produce a segmentation fault depending on how lucky you are. Some people seem to disagree, one of them being my professor.

Ghost

#3
Quote from: Paper Carnival on Sat 20/12/2008 14:52:05
I personally think there should never be a problem, as long as you don't attempt to read/write over it, which may or may not produce a segmentation fault depending on how lucky you are. Some people seem to disagree, one of them being my professor.

What you describe is the equivalent of leaving a loaded shotgun lying around. As long as you're alone in the room, nothing will happen because you know that shotguns are harmful things. But as soon as people come in, one of them *will* shoot himself in the foot(*).
You can get errors by using a pointer that way, and also memory leaks and all sorts of other nasty stuff, but you yourself know about that and will be careful. Others using your code will not. And since there is the common saying that code should always be fool-proof, I understand your professor's concerns.  ;)

(*) Heaven knows I always do that ;)

Paper Carnival

well, basically, we were having an example on how to use pointers instead of arrays.
Code: ags
//p is a pointer 
for (i=0; i<MAX; i++)
{
    *p++ = i;
}

I know it's convenient to just say p[i ]=i, but this is for the sake of an example. Note that p is never used again after this code. This shouldn't ever produce a segmentation fault, right? Even though, when the loop ends, the pointer points to a place we don't know... But my professor insists that the above code might cause a segmentation fault.

Ghost

#5
Quote from: Paper Carnival on Sat 20/12/2008 15:55:10
But my professor insists that the above code might cause a segmentation fault.

I'm not rock-steady on the whole pointer issue, but as long as he says MIGHT, he's right. Because at the end of the loop, the pointer could point anywhere, even to a segment of memory another bit of your code is already using. That's where a violation might happen, though the chance is small, and grows smaller the more RAM you have.


Paper Carnival

Sorry for taking over the thread, but...

I'm not convinced. Every variable, including pointers, has a value when declared (which is what was left in the memory from other programs). Pointers having a "random" value when declared never generated any problems. So why now?

My other professor says that the above code never produces a segmentation fault. As long as you don't access that memory slot in any way (either read or write over it), it's all good.

Another opinion I heard is that it can only produce an error in some operation systems but not all.

I know it's pointless knowing anyway, because nobody would even want to have stray pointers, but it has been bugging me a lot :P

LimpingFish

How do they get the figs into the Fig Rolls? :-\
Steam: LimpingFish
PSN: LFishRoller
XB: TheActualLimpingFish
Spotify: LimpingFish

(deleted)

#8
(deleted)

bicilotti

Quote
Next Question:
What are the... err, uhh... qualifying, requisite required requirements for an AGS game's eligibility for the 2008 AGS awards? I realize that I'm an idiot for asking, and that's why I'm asking here instead of somewhere else. (Not that anything with me on board is worth the sand in Nelly's sock heels. Just seeking deadline motivation, is all.)

Put it in the big database before 1st Jan 2009 and you're in!

RickJ

Quote
I personally think there should never be a problem, as long as you don't attempt to read/write over it, which may or may not produce a segmentation fault depending on how lucky you are. Some people seem to disagree, one of them being my professor.
@Paper Carnival:  Your professor is wrong.  A "segmentation fault" is a hardware interrupt generated in response to a memory read/write to an address outside of a range specified by a register or RAM table of some sort.  The setting of a pointer variable to a value will cause a memory write to the address of the pointer variable but not to the address which it contains.   Read and write signals to the pointer's address are not issued until memory at that address is accessed.  Since there is no memory access there will be no interrupt and hence no segmentation fault.  This is all done in hardware so the operating system is irrelevant.   It's entirely possible to have a software segmentation fault checker but the overhead would be extremely high and I have never heard of it being done.

I agree with you that this should never be a problem and I'll give a couple of good reasons why.  First of all let us assume that we have an application that contains some code similar to the one you give.  Further let us assume that this is application is a closed loop controls system controlling the flying surfaces on a 757 Jumbo Jet.  And just to make things interesting let us also assume your professor is a passenger on the same plane flying at 35000 ft.

1.  Fault response - How should our application respond to a segmentation fault of the variety that you describe (i.e. the application is otherwise operating normally and will continue to do so if the fault is ignored)?  There are two obvious choices; abort the application or ignore the fault.  In this instance I believe your professor would prefer the control system ignore inconsequential segmentation faults be ignored rather
plunge to his death.   What about other applications?  Can you name any application where it is better to crash than to continue running normally?  So if the only reasonable response to a fault condition is to ignore it then what purpose does it serve to detect it.

2. Reliability/Maintainability - No suppose our application is very mature.  It has been in use on thousands of aircraft for over a decade.   With millions of total hours of operation our application has proven to be stable and reliable.     Now suppose that a single line of trivial code, unrelated to the pointer in question, is added and the application is recompiled.  What if over all these years that last p++ left p just a byte shy of the segment boundary and the new code pushed it just one byte past.    This is a horrible situation - In a complex application it could be a long time before such a bug finally revealed itself.  In this kind of situation any kind of changes made to the application, regardless of how small or trivial, would incur huge and unacceptable risks.

3. Redundant-Convoluted Code - In the scenario you give in the example the pointer value would have to be tested before incrementing it.   So either there must be a redundant if statement (there is already a p<MAX test) before incrementing the pointer or the loop must be restructured in a less obvious and understandable way (which would also likely involve redundant code in one way or another.   No useful purpose is served by requiring redundant and/or convoluted code.  In my opinion redundant, convoluted code fits Ghost's description of "...leaving a loaded shotgun lying around...." much better than a pointer containing an invalid address.

4. Runtime vs Compile Error - If the compiler were able to pick this up then it could be argued that knowing that a pointer contained an invalid address could be useful in some cases.   However this is not the case; segment faults occur at runtime and may not occur until long after the application has been released and in the field.

InCreator

#11
My unanswered mystery of all time:

Is nerve impulse physical? I mean, is it an electric, bioelectric, anything material we could capture or transfer?
If so, can we redirect nerve impulse into something else? Like a wire? Third string of nerves, like animal ones?
I know that if you lose a finger, it can be sewn back and nerves too. So, it's likely. Why havent anyone then thought about...

-- Is is possible to connect nerves of two people so if one gets hammered onto toe, another one yells?

Also, another big riddle is - where could I actually get answers to questions like this? I mean, apart from having physics/anatomy/whatever professor as a friend? Internet might have everything, but sometimes seems to lack very basic knowledge of scientific progress. Wikipedia/howstuffworks/etc well-known sites are brief and other sites are either well hidden or non-existing.

Kind of sad that the flagship of information age can satisfy any crazy request for porn, but not knowledge...  >:(

Ghost

#12
Quote from: InCreator on Mon 22/12/2008 05:22:59
Is is possible to connect nerves of two people so if one gets hammered onto toe, another one yells?

Weird thought, but I can see that this should be possible. All a matter of finding the right nerves and connect those- but it would require a physical connection, wouldn't it? So you'd need to sew these people together somewhere, which has a very Hellraiser touch to it.

Paper Carnival

Thank you RickJ for clearing that up. My professor is often wrong with details like this, but at least the man knows how to teach. It's only my first semester in university and I'm glad I can understand when he's wrong (it's not the first time).

InCreator: I suppose it is possible, but still freaky. And Ghost, I don't think it would require a physical connection, both people could have some kind of transmitter/receiver that picks up the nerve signal and convert it to something else and vice-versa, like a modem works. I'm next to clueless with this stuff, so correct me if I'm wrong.

Oh, the transmitter/receiver idea would make the concept of a voodoo doll possible :D.

InCreator

#14
QuoteOh, the transmitter/receiver idea would make the concept of a voodoo doll possible

Man, think BIG! Think gaming!!!!

A wireless spinal impulse controller! Like play Crysis and actually feel tropical breeze on your face, taste salt water and smell gunpowder... whoah! And coming back to porn... eh

Babar

I think I know how this movie ends...
The villain overloads the circuits, and kills everyone in real-life that he kills in VR. And then the hero comes and busts everything up.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Paper Carnival

Quote from: InCreator on Mon 22/12/2008 16:11:03
QuoteOh, the transmitter/receiver idea would make the concept of a voodoo doll possible

Man, think BIG! Think gaming!!!!

A wireless spinal impulse controller! Like play Crysis and actually feel tropical breeze on your face, taste salt water and smell gunpowder... whoah! And coming back to porn... eh

That's like... The Matrix.

But now you mention it, wasn't there some kind of experimental microchip they put on someone's brain, and he then was able to kinda move the mouse pointer with his mind ???

Stupot

Quote from: RickJ on Sat 20/12/2008 04:41:34
There's always the wayback machine : http://web.archive.org/collections/web.html

Thanks Rick... I spent a while on that typing in the kinds of domain names the site would have used, but I'm not getting any results... does anyone else remember what I'm talking about [Re: first post] ?

Joseph DiPerla

I am looking for a c++ pathfinding library that is supported on atleast windows, mac and linux. Is there any out there that can work just by loading an image as a mask and making that be a pathfinding area? Basically the way any other engine works, just as a c++ library.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Ryan Timothy B

Someone here in this thread had mentioned something about someone making around 100 games a year, for some kind of competition or for school perhaps?  But the guys ended up not finishing them.

I've been trying to find the thread that someone had made mention of this.  They also supplied a URL to this persons website.  I'm trying to find that website.
I had bookmarked it back in the day, but I formatted not too long ago and it's gone.  I kept meaning to take a good look at the website and games.

SMF spam blocked by CleanTalk