User forums > Using Code::Blocks

Program works in CB terminal, but seg faults in Linux terminal?

(1/1)

Greystoke:
I have a small-ish program that seems to works fine in the Code::Blocks terminal window (I get all the output, it exits normally).  But if I go to a Linux terminal and run the same program, I get a segmentation fault.  (Open a new terminal window, CD to the directory, do "./program".)  Anyone have any ideas about this?  What should be looking at?

I did compile it with -fprofile-arcs and -ftest-coverage flags, BTW.

Thanks!

-G

Jenna:
Do you try to read from a file or something similar, that depends on the working directory ?
If yes, check whether you test the vaildity of the (file- or whatever) handlers before using them.

Greystoke:
No, I am not reading from any files.  The profiling/gcov stuff does, however...

Oh bollocks.  I reconfigured it to not do profiling and now it crashes in Code::Blocks, too!  :)

But it runs fine (in CB anyway) if I use my debug profile/target.  I can't find any culprits as to why there's a difference, either.  (I'm rather new at this, so I am probably missing something obvious.)

-- G

stahta01:
The likely problem is your code is bad; as in you are reading or writing to memory you have to rights to access.
The above is not a topic for this site. Try cboard for code issues. http://cboard.cprogramming.com/general-programming-boards/

Tim S.

Greystoke:
Actually, it was my own dumb fault; similar to my code being bad, but different.

I had set a 'program arguments' for my CB profile when executing that build target.  I had forgotten about that when trying to run it manually.  When I included the command line argument in a native terminal, it worked fine. 

DOH!  :)

Navigation

[0] Message Index

Go to full version