Sponsored Content
Top Forums Programming Is there a limit for a code line length in C? Post 302431666 by alex_5161 on Tuesday 22nd of June 2010 12:31:29 PM
Old 06-22-2010
I have a source where some weird condition unstably produces the Segmentation Violation.
The error could disappeared or be moved into different place by adding/removing some line of code (some printf() and additional declaration/definitions.)
By 'dbx’, I see how some variable changed unexpectedly into impossible values.
I see the resulted change when the variable is used, but I can't catch when it is happening (the variable change itself!)
It still could be a logical error in code, but working on that problem already couple weeks (before last changes it works fine when I have removed all debug-statements) I start to think about some extreme situation, related to system (maybe our, maybe the standard one.)

I have reviewed today the code with expanded all macros (thanks to JohnGraham for advise how to do that!) and I see some line after that reach 4096 characters long and I am not sure by now if the line is braked in code or it is done by the editor (I use UltraEdit )
Just realized, that it is right - the lines are braked by the editor and actually, in code they are longer: the one I have reviewed now is 4096+1537 = 5633.
There are some code lines, consist of couple of 4096-chars lines.

Therefore, I've been thinking if a long code line in some situations comes across the processing memory, having the debug option is on...

(... Writing, I've thing that the memory for code and the processing memory used in different time... and debugging information does not include the '-E'-code lines, but just references to the original source file..., but ... not completely sure if the so long lines of code is not a reson of that error ...)

Therefore, I've asked this question trying to review any possibility for that error...

If you would have some idea or advise what else I could do to catch the error, I will appreciate to hear it very much!

Last edited by alex_5161; 06-22-2010 at 01:38 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep line length limit

Hi Friends, I am having a funny problem with grep. When I run grep 'expr' file.txt things work fine. But when try to get the line number using the -n option, i.e, grep -n 'expr' file.txt I get a message, "grep: 0652-226 Maximum line length of 2048 exceeded." If the line has more than... (3 Replies)
Discussion started by: hnhegde
3 Replies

2. AIX

Is the Length of User ID for AIX Limit to 8 Characters?

Hi, I'm using AIX version 5.3 currently. I'm trying to create a user id, e.g. andyleong, which the system prompted the length is too long. 1. I would like to know is that the length of user id is limited to maximum 8 characters for AIX. 2. Is it apply to all versions of AIX? If no... (2 Replies)
Discussion started by: meihua_t
2 Replies

3. UNIX for Dummies Questions & Answers

limit of command length

Hi! Can you please help me with one question? Does rexec command have some limitation of the length of the deliveded cmd? Thanks in advance, Anta (2 Replies)
Discussion started by: Anta
2 Replies

4. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

5. Cybersecurity

~ IPTables : Limit Incoming UDP Packets With a Certain Length ~

Hello, I am currently trying to limit incoming UDP length 20 packets on a per IP basis to 5 a second using IPTables on a Linux machine (CentOS 5.2). Basically, if an IP is sending more than 5 length 20 UDP packet a second to the local machine, I would like the machine to drop the excess... (1 Reply)
Discussion started by: tomboy123
1 Replies

6. Shell Programming and Scripting

AWK limit for (length) function?

I am trying to use the following code: awk '{s=$0;if(length(s) < 750){getline; s=s " " $0}printf("%s\n",s)}' filename but an error shows that 'awk' is too long. Is there a limit to the awk length function? and what could be an alternate solution for long fixed width records? The code... (3 Replies)
Discussion started by: CKT_newbie88
3 Replies

7. Shell Programming and Scripting

perl file, one line code include "length, rindex, substr", slow

Hi Everyone, # cat a.txt a;b;c;64O a;b;c;d;ee;f # cat a.pl #!/usr/bin/perl use strict; use warnings; my $tmp3 = ",,a,,b,,c,,d,,e,,f,,"; open(my $FA, "a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\;/, $_); if ( ($tmp =~ m/^(64O)/i) || ($tmp... (3 Replies)
Discussion started by: jimmy_y
3 Replies

8. Programming

Limit line for perl

Hey guys, can help me out with this? How do i limit output for xml to 50 character? i tried *below* but doesnt work, it still print more than 50 characters. Thanks in advance printf "%-50s", "$testline\n"; (4 Replies)
Discussion started by: Nick1097
4 Replies

9. Shell Programming and Scripting

Check for length which exceeds specified length in a line

Hi, I have a issue, I need to loop through a comma delimited file and check for the length which exceeds specified length , if Yes truncate the string. But my problem is , I do not have to check for all the fields and the field lenght is not same for all the fields. For ex: Say my line... (9 Replies)
Discussion started by: rashmisb
9 Replies

10. Shell Programming and Scripting

Limit string length with sed

Hi. I'm trying to learn sed. I want to limit the length of a string. I tried this: sed -n 's/^\(...........................\).*/\1/p' textfile.txt This works fine, but how do I give it as a range rather than putting a hundred dots? I'd like to limit the number of characters to 144 for... (3 Replies)
Discussion started by: troglodytes
3 Replies
Perl::Critic::Policy::InputOutput::RequireBriefOpen(3pm)User Contributed Perl DocumentatioPerl::Critic::Policy::InputOutput::RequireBriefOpen(3pm)

NAME
Perl::Critic::Policy::InputOutput::RequireBriefOpen - Close filehandles as soon as possible after opening them. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
One way that production systems fail unexpectedly is by running out of filehandles. Filehandles are a finite resource on every operating system that I'm aware of, and running out of them is virtually impossible to recover from. The solution is to not run out in the first place. What causes programs to run out of filehandles? Usually, it's leaks: you open a filehandle and forget to close it, or just wait a really long time before closing it. This problem is rarely exposed by test systems, because the tests rarely run long enough or have enough load to hit the filehandle limit. So, the best way to avoid the problem is 1) always close all filehandles that you open and 2) close them as soon as is practical. This policy takes note of calls to "open()" where there is no matching "close()" call within "N" lines of code. If you really need to do a lot of processing on an open filehandle, then you can move that processing to another method like this: sub process_data_file { my ($self, $filename) = @_; open my $fh, '<', $filename or croak 'Failed to read datafile ' . $filename . '; ' . $OS_ERROR; $self->_parse_input_data($fh); close $fh; return; } sub _parse_input_data { my ($self, $fh) = @_; while (my $line = <$fh>) { ... } return; } As a special case, this policy also allows code to return the filehandle after the "open" instead of closing it. Just like the close, however, that "return" has to be within the right number of lines. From there, you're on your own to figure out whether the code is promptly closing the filehandle. The STDIN, STDOUT, and STDERR handles are exempt from this policy. CONFIGURATION
This policy allows "close()" invocations to be up to "N" lines after their corresponding "open()" calls, where "N" defaults to 9. You can override this to set it to a different number with the "lines" setting. To do this, put entries in a .perlcriticrc file like this: [InputOutput::RequireBriefOpen] lines = 5 CAVEATS
"IO::File->new" This policy only looks for explicit "open" calls. It does not detect calls to "CORE::open" or "IO::File->new" or the like. Is it the right lexical? We don't currently check for redeclared filehandles. So the following code is false negative, for example, because the outer scoped filehandle is not closed: open my $fh, '<', $file1 or croak; if (open my $fh, '<', $file2) { print <$fh>; close $fh; } This is a contrived example, but it isn't uncommon for people to use $fh for the name of the filehandle every time. Perhaps it's time to think of better variable names... CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation. AUTHOR
Chris Dolan <cdolan@cpan.org> COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module perl v5.14.2 2012-06-07 Perl::Critic::Policy::InputOutput::RequireBriefOpen(3pm)
All times are GMT -4. The time now is 08:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy