Technical article 100815

Calling realpath(S) from within my program causes a core dump.

OpenServer 5.0.0

Written · Last revised

Problem

If I make a call to realpath(S) from within my source I find that, when compiled, the resulting binary will terminate with the error:

Memory fault(coredump)

Cause

The character buffer passed to realpath(S) is being passed to
a function called pathcanon().  This function is calling getcwd(S)
with a buffer size of 4096 bytes.  getcwd(S) clears this buffer
and overruns the stack causing the core dump.

Solution

This problem has been reported to SCO Engineering.

To work around this problem, make sure that the character buffer passed to realpath(S) is 4096 bytes in size:

char buff[4096];
realpath(filename, buff);

where 'filename' is the name of the file whose path you wish to resolve.

From the Xinuos technical article database, record 100815. Reproduced with permission. The original is at www.sco.com/ta/100815, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.