#118 (getcwd(NULL,0) fails on Solaris causing -g dwarf2 to crash) – The Yasm Modular Assembler Project

Ticket #118 (closed defect: fixed)

Opened 15 months ago

Last modified 15 months ago

getcwd(NULL,0) fails on Solaris causing -g dwarf2 to crash

Reported by: bird-yasm@… Owned by:
Priority: P1 Milestone:
Component: Core Version: 0.6.0
Severity: normal Keywords:
Cc:

Description

getcwd(NULL, 0) is undefined behavior according to SuS. On GNU/Linux and *BSD it work like you expect, while on Solaris it will fail (because size is 0) and crash when the NULL pointer is accessed.

A quick workaround would be to pass PATH_MAX (limits.h) instead of 0 on Solaris.

Attachments

Change History

comment:1 Changed 15 months ago by peter

  • status changed from new to closed
  • resolution set to fixed

(In [2004]) Fix #118: Don't use getcwd(NULL, 0), as it's platform-specific behavior.

Instead write our own yasmgetcwd() which retries getcwd() with increasing buffer sizes until the path fits (as the initial size is 1024, in basically all cases it'll succeed on the first try).

Reported by: bird-yasm@…

comment:2 Changed 15 months ago by bird-yasm@…

Tested the fix on Solaris with both 1024 and with 4 as the initial buffer size, it works like a charm. Thanks!

Add/Change #118 (getcwd(NULL,0) fails on Solaris causing -g dwarf2 to crash)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.