Author Topic: Seg fault with extern's  (Read 13519 times)

nemotux

  • Guest
Seg fault with extern's
« on: May 10, 2005, 02:07:28 PM »
Hello, I'm new to nasm and am trying to port a tool to it that generates asm code (currently generates tasm code).  The tool may generate a large number of extern declarations for each asm file.  Granted most of these are not actually used in any one asm file (this will be eventually remedied).

Anyway, it seems like for every 256th extern declaration, using the corresponding symbol causes nasm to seg fault. For example, I have something like:

...
  extern loc_0
  extern loc_1
  ...                     ;; 253 other extern declarations
  extern loc_255
  ...

jmp loc_255

With the "jmp loc_255", nasm seg faults.  Without it, everything runs fine.  If I add an extra extern before the extern for loc_255, then it also works. ie. if I do this:

...
  extern loc_254
  extern blah
  extern loc_255
  ...

I observed similar results for loc_511, and loc_757.  I haven't exhaustively checked the remaining symbols, but it doesn't seem like there's a problem for other symbols.

Is this a known problem?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Seg fault with extern's
« Reply #1 on: May 10, 2005, 04:58:39 PM »
Semi-known... sounds like it might be the same thing as #1001394 in the bugtracker. In that case - similarly, machine generated code with lots of "extern"s - it *seemed* as if it were some number of "repetitive" externs (many externs for the same symbol) that was causing the problem. Your observation that it happens every 256 externs, and then only when you use the symbol, may be an important clue. I don't know how "actively" this bug is being persued - I'll confess *I* haven't looked at it for a while - but I think it's the same as a "known" problem. I'll create a "test file" based on your info, and see if a simpler test will help reveal the problem...

Thanks for the feedback!

Best,
Frank

nasm64developer

  • Guest
Re: Seg fault with extern's
« Reply #2 on: May 10, 2005, 06:15:29 PM »
I have attached this as yet another sample
to SF bug #1001394.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Seg fault with extern's
« Reply #3 on: June 18, 2005, 03:00:55 PM »
I've committed a patch that I hope will fix this. It'll be in the next release (0.98.40 - who knows when?) If you want to try it out, grab the code from the CVS repository. (or get in touch)

Your observation that it was every 256th extern that caused the problem turned out to be a *tremendous* help in finding the little rascal!

Best,
Frank