64-bit eggdrop builds crash on some systems #2

Closed
thommey opened this Issue Feb 2, 2010 · 0 comments

1 participant

@thommey
Eggheads member
Trac Data
Ticket 2
Reported by pseudo
Status closed
Component Core
Priority blocker
Milestone 1.6.20
Version 1.6.20

Eggdrop crashes on *BSD/amd64 and likely on 64-bit big-endian architectures.
Crashes usually happen in modules allocating memory trough mod_malloc() but are
potentially possible in various other places.

The root of the problem is the assumption that pointers are of the same size as
ints, which is correct for a 32 bit data type model, but obviously not for
64-bit build environments. Pointers and ints are used interchangeably
everywhere in the source code, which leads to crashes when a garbled pointer is
dereferenced.

The crash on BSD systems is unconditional due to the fact that malloc()
allocates high addresses by default (which don't fit into an int). Users of
FreeBSD can avoid a crash on startup by setting the MALLOC_OPTIONS environment
variable:

env MALLOC_OPTIONS='Dm' ./eggdrop

This will make malloc() to map lower addresses so that truncating a pointer to
int might not lose meaningful information and eggdrop will be able to run.

The bug needs to be fixed by removing any casts of pointer to int and changing
function arguments and variables to use proper data types suitable for their
purpose.

@thommey thommey closed this Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment