[ nedit-Bugs-1625283 ] Macro branch operations may crash on 64-bit
systems
SourceForge.net
noreply at sourceforge.net
Tue Jan 2 19:46:05 CET 2007
Bugs item #1625283, was opened at 2006-12-31 05:40
Message generated for change (Comment added) made by tringali
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=111005&aid=1625283&group_id=11005
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Program
Group: release
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Juergen Keidel (keidel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Macro branch operations may crash on 64-bit systems
Initial Comment:
Building from Source on Linux with a 64-bit system leads to several error messages (casting from/to int from/to pointer.
After solving these compiler messages, the program runs. Using the preference file, it aborts with segfault when inserting something.
Without preferences (no Macros) it works.
Abort happens in ContinueMacro
at : status = (*inst)();
The 32-bit version with same preference file runs stable.
----------------------------------------------------------------------
>Comment By: Scott Tringali (tringali)
Date: 2007-01-02 13:46
Message:
Logged In: YES
user_id=11321
Originator: NO
The problem I see is that branching stuff in the parsing phase puts void*
onto the stack, but pulls them off as integers (see AddImmediate vs.
branchTrue).
I changed them both to integers and made it more type-safe with a union,
so the instructions won't take up any more space. There seems to be no
reason for the cast to void* that I can find. The file now compiles with
no warnings.
I think the downside is that you can only branch an int's worth, instead
of of large. A better solution would to make all the branches be of
ptrdiff_t, but since macros are limited to a few K it doesn't matter.
Would so someone who knows this better take a look?
File Added: int.diff
----------------------------------------------------------------------
Comment By: Scott Tringali (tringali)
Date: 2007-01-02 12:37
Message:
Logged In: YES
user_id=11321
Originator: NO
Need a bit more detail on your 64-bit system. What CPU? Distro? Compiler?
Version of NEdit?
I don't dispute the code in there is wrong, it would help us to fix it if
we can actually repro it. It doesn't repro for me on other 64-bit sytems I
have access to.
BTW: casting to long it will only put off the problem to another day for
another platform.
----------------------------------------------------------------------
Comment By: Juergen Keidel (keidel)
Date: 2007-01-02 04:06
Message:
Logged In: YES
user_id=86514
Originator: YES
The reason for the segfault lies in interpreter.c, handling of branches.
getting a value from PC results in compilerwarnings about different sizes
of pointer and int. solving this by casting the void * of PC to long int
get an address-like expansion of the value (i.e. extended to
0x7fffffff00000008 p.E)
So the branching functions in interpreter.c must mask (or shift left32 and
right back 32-bit of the value)
This old trick of storing values in a pointer-location has problems at
64-Bit systems.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=111005&aid=1625283&group_id=11005
More information about the Develop
mailing list