Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Segmentation Fault, Segmentation Violation, Bus Error, Stack Smashing

Have you ever had these error messages come up from your C program and wondered what they really mean?

Segmentation Fault

Segmentation Violation

Bus Error

stack smashing detected


A segmentation fault is when you try to access memory that doesn't exits. A segmentation violation is when you try to access memory that's not your process's. A bus error is when you try to an address that points to the memory bus. Stack Smashing is when you try to reduce the stack to less than zero in size.

But they really all mean the same thing - you've made a mistake with your addresses and pointers, called a function (in K & R C) with the wrong number of parameters (or got a wrong function prototype in ANSI C), or you've overrun an array and corrupted something.

A great deal of moving from being a new C and C++ programmer to an efficient and experienced one is about knowing how to naturally avoid messages like these in the first place, and about learning how to quickly spot the cause when they do occur.

Can I make a strong recommendation? Write your code in named blocks - functions or methods, build test programs for those named blocks, keep your tests so you can run and rerun them. You won't eliminate the segmentation, stack and bus errors - but you will help yourself find them in a relatively small area of code. Informally, I'm recommending that you move towards test driven, or behaviour driven, development!
(written 2014-12-04, updated 2014-12-03)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C208 - C and C based languages - Programming techniques and tools
  [4336] Test Driven Development - a first example of principle in C - (2014-12-01)

C050 - C and C based languages - C - General
  [2002] New C Examples - pointers, realloc, structs and more - (2009-01-20)
  [2086] C Programming v Learning to Program in C. Which course? - (2009-03-17)
  [2091] C, C++ and C# ... Java and JavaScript - (2009-03-20)
  [2504] Learning to program in ... - (2009-11-15)
  [2536] All the Cs ... and Java too - (2009-12-13)
  [2669] Efficient use of dynamic memory - C and realloc - (2010-03-10)
  [2763] Our C and C++ training course are on Open Source platforms - (2010-05-13)
  [2848] C course - final course example puts it all together - (2010-07-02)
  [3053] Make - automating the commands for building and installing - (2010-11-16)
  [3129] Extra courses - C and C++ - (2011-01-12)
  [4335] Flexible public courses - residential or commuting, programming newcomer or experienced, C or C++ - (2014-11-30)
  [4434] Public training courses - upcoming dates - (2015-02-21)


Back to
Simple C structs - building up to full, dynamic example
Previous and next
or
Horse's mouth home
Forward to
My first official measure - Passenger Entrys and Exits - revisited 9 years later
Some other Articles
Incrementing a variable in Java - Pre and Post Increment
Python base and inherited classes, test harness and unit testing - new examples
Politics and the railway the connects Wiltshire
My first official measure - Passenger Entrys and Exits - revisited 9 years later
Segmentation Fault, Segmentation Violation, Bus Error, Stack Smashing
Command line and file handling in C
Simple C structs - building up to full, dynamic example
Passing arrays into functions in C
Learning to program sample program - past its prime, but still useful
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4341_Seg ... hing-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb