question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Large, single-file sources of F# get the line number and debug-stepping totally wrong

See original GitHub issue

If your source file is sufficiently large (essentially, over 2^16 or 64k lines long) the line number used when source stepping, or the curlies that you on syntax errors, are reported on totally wrong lines (essentially, current line minus 216).

This may not happen often in practice, but if it happens, it is highly confusing. I suggest to either raise a compile error “source file to large, maximum of 65535 lines reached, consider splitting your source in multiple source files” or to allow a integer instead of a short for the line number counter. I don’t think it is a limitation of .NET or Visual Studio, large auto-generated source files in C# do not exhibit this problem.

A practical issue with this is specifically autogenerated files, for instance, we use a Dynamics CRM mapping which generates a single file of 350k lines for the entity mappings using Microsoft tooling. Converting that to F# is currently not an option.

Since the auto-created function names use line numbers to identify them, this has the effect that line numbers on such functions point to the wrong location. I have not tried whether this could confuse the compiler in creating such names.

This was also reported on StackOverflow with a screenshot.

See how the debugger stops at a blank line, how the selection is wrong, and how the code-coverage tools report non-existing lines as hit:

b4afq

A by-product of this behavior is that setting a breakpoint with F9 will actually set it on the non-existing line, as if no breakpoint was set on the actual code.

Note, surprisingly, __LINE__ stores the correct line information.


PS: previously, and in some comments, this entry also showed an example that, next to the wrong line numbers being reported, also crashed Visual Studio. I have now moved that into a separate bug entry: #779.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cartermpcommented, Oct 25, 2018

Fixed in #4476

0reactions
abelbraaksmacommented, Oct 29, 2018

Fantastic! Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

eclipse debugging shows source files with wrong line ...
In Eclipse, go to Project > Clean... , select your project and press OK;. If you get errors at step #3 (like Access...
Read more >
At what point/range is a code file too big?
So a source file that is more than 2000 lines is probably too large and starting to be too messy. This is really...
Read more >
can't breakpoint into source code - error 35: undefined line ...
Hi, I am having trouble to breakpoint into the stm32f10x_can.c code. Got a error 35 and undefined line number.
Read more >
Find String List - line number incorrect on large Unicode ...
Find String List contains the correct line numbers for all lines if I use File Open command and select ASCII (ansi code page...
Read more >
Wrong Line Numbers in Error Messages
The source file has a big preamble, but NO include or input files. Why do line numbers in error messages are completely wrong?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found