Too Many Segdef (Compiler Error)

The “Too Many Segdef” compiler error has plagued my life for a few years now.

In the most layman of terms (because that’s how my brain works) it means: You have a procedure somewhere that has way too many lines of code, template or otherwise.

Specifically for me, it’s because I’ve been working with Nettalk and creating some very large forms.

So this post is related mostly to Nettalk (NetWebForms in particular). Am not sure how much it will hold with regular clarion (desktop) apps.

There are a couple of bits of wisdom I’ve gleaned (through others helpfulness!) that would be good to document so others can hopefully be helped.

PROCESS

0. Make sure you have moved the big procs into “1 per module”, or just do them all 1 per module if that’s easier.

1. If you get this error, go to your *.clw files and find the *.clw file causing the issue (sort by size is a good start). I keep all my clw files in their own folder, so it’s easier in that way, but whatever the case of your development environment, you need to find the clw. It’ll be one that’s pretty large.

2. Once you have the clw, you can work out the procedure that is causing the issue. Now when it happens, I’ve got a pretty good idea which one it was (it’ll be the form I just added something to, one of a couple of netwebforms that are sitting right at the edge of “too many segdef”).

3. Once you have the troublemaking form in your sights, you have a couple of choices.

CHOICE #1: Try and minimise the template code in the form.

With NetWebForms (Nettalk), there are a couple of things that can be done. You can, if you have a form where this won’t interfere, turn off all comments for the form. This will significantly reduce the amount of template code in the form. But you lose comments (full stop, no way around it except to hack Bruce’s beautiful template code).

You can also look at removing any redundant fields, perhaps merging fields whose functionality might be duplicated elsewhere in the form.

CHOICE #2: Rip the form to bits (with pen and paper first usually!) and rebuild it with multiple interfaces.

If you have a form that’s hitting the “too many segdef” error, then you have a big form.

You want to look at breaking it up regardless. Having lots of tabs/sections, scrolling for miles, none of that is ideal when you could swap out for half a dozen buttons that launch popup forms instead.

In my experience I’ve usually taken both of those options.

Here’s a screenshot of the once-too-many-segdef “Person” netwebform, now broken up into multiple interfaces with what I call “popup buttons” (urg).

Hope this helps.

3 Likes

Thanks for this Stu.

I have this problem in my data dll, seems my dictionary is too big. I have switched the “Generate File Declarations in Modules” to on in the Global properties but that did not fix the problem. I already removed all possible obsolete/unused tables from the dictionary, cleared all the clw/inc/obj/map etc. and recompiled but still getting the segdef error.

Any ideas on how to fix this?

Thanks

Nardus

Hey Nardus,

Did you sort the clws by size to find the “big” files, and then look at the procs in those modules?

If you’re getting this on a nettalk app, it can be because of a big form (although Bruce has done a lot of work on sorting this out).

Hi Stu

It is the clw with the file declarations. Not a NetTalk application.

I do have NetTalk applications but this specific app is a Windows app.

Thanks

Nardus

Right, the clw with file declarations.

If you use FM3, you might be able to do a large dictionary split (can’t remember what it’s called), that might help.

If you are still seeing the declarations in the main module, then I’m not sure this switch is on. Do you perhaps have Multi-Proj in this app? That doesn’t support this switch.

Hi Bruce

I am not using Multi-Project, I have switched that on and off recompiled every time, export to TXA, create new app from TXA, delete all source, obj, etc files and recompiled again but still getting the too many segdef error due to declarations in main module.

Thanks

Nardus

Used the Very Large Dictionary Support in Capesoft’s FM3 and that solved the issue for me.

Thanks

Nardus

Hi Guys,

I have this exact problem in a desktop app (not Nettalk) when I added 6 alias tables to my dictionary. We were already using the FM3 VLDS.

What I have done so far:

  1. Added a 3rd FM3 VLDS proc to the separated FM3 exe app.
  2. Enabled the ‘Generate file declarations in all modules’ option in the data dll app.
  3. Deleted all map/obj/clw etc files.
  4. Re-compiled all apps.

The ‘too many segdef’ error message is no longer there but my app crashes on start-up with these error messages:

I have then updated multi-proj in the data dll with the higher BC number that was generated and compiled again but still have the same error messages appear on start-up.

Apparently windows error code 0xc0000096 means that there are windows system file corruptions but running ‘sfc /scannow’ multiple times found no issues.

Does anyone have any ideas on what to do next? This is now becoming urgent to get fixed for my customers. Any help is appreciated.

Regards,
Trent

Hi Trent,

Do you have Capesoft’s GPF Reporter?

That + Debug compile should help you track down where things are going wrong.

Hi Stu,

GPF Reporter didn’t work. It doesn’t show a GPF when all apps are compiled in debug mode.

Regards,
Trent

Further to this, I have removed the 6 alias tables and disabled the ‘Generate file declarations in all modules’ option in the data dll app. Re-compiled everything and the app works again without crashing.

As soon as I enable the ‘Generate file declarations in all modules’ option in the data dll app the app crashes on start up with the same error message previously attached.

At the moment this means I can’t add any new tables or aliases to my dict without breaking the data dll app.

Any other suggestions?

Regards,
Trent

Hi Trent

Are you using the IMDD Cache template? If you are, try removing it and recompile and see if your app still GPFs. Someone somewhere said if you move the place where the IMDD Cache template is initialized the error goes away but I have not tested it myself.

1 Like

Hi Nardus,

This was it! After removing IMDD from the data dll the app doesn’t crash. Adding the IMDD template back in and recompiling works too.

Thanks everyone and regards,
Trent

I recently bumped into the dreaded “too many segdef” error with a brand new NetTalk build. It turns out to be the “tyranny of the default” in my case: The IDE is set to 10 procedures per module by default. Bruce recommended I change it to 1:

So Application Menu, Repopulate Modules, 1
makes for more (smaller) CLW’s and then the app compiles fine.
Ultimately it is possible to hit segdef errors even with 1 procedure per module, for procedures with sufficient fields, but you’re not near that limit yet.
Oh, and the “procedures per module” thing is a setting you can set;
Tools / Application Options / Application tab / Procedures per module.

I followed this advice and the same app compiled perfectly. What a relief!

2 Likes

Yeah this is super important, thanks @DonnEdwards!

I can no longer edit the post, otherwise I’d get it in there as the first step.

  1. Make sure you have moved the big procs into “1 per module”, or just do them all 1 per module if that’s easier.

Cheers Donn and Bruce :slight_smile:

I uploaded an APP Split tool I had that was made to find large Modules and Procedures. I would be curious for you to run it against your APP and see if it does identify your largest procedures.

Finding the largest modules is easy by just sorting by CLW file size. Not shown, I did add columns with the OBJ and RSC size to this list.

Finding the largest Procedure size is done using the Linker Map addresses.

image

AFAIK the MAP is not documented. I think I have code size and not data size.

3 Likes

Awesome stuff Carl. Will give it a whirl!